Browse Source

fix: spec

RyaneMax 8 months ago
parent
commit
326c83db60

+ 1 - 3
src/modules/contact/chat/chat.page.spec.ts

@@ -1,8 +1,6 @@
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 import { IonicModule } from '@ionic/angular';
 
-import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
-
 import { ChatPage } from './chat.page';
 
 describe('ChatPage', () => {
@@ -12,7 +10,7 @@ describe('ChatPage', () => {
   beforeEach(async () => {
     await TestBed.configureTestingModule({
       declarations: [ChatPage],
-      imports: [IonicModule.forRoot(), ExploreContainerComponentModule]
+      imports: [IonicModule.forRoot()]
     }).compileComponents();
 
     fixture = TestBed.createComponent(ChatPage);

+ 2 - 0
src/modules/contact/contact-list/contact-list.page.html

@@ -65,4 +65,6 @@
       </ion-item>
     </ng-container>
   </ion-list>
+  <ion-button type="button" (click)="clicked()">Click me!</ion-button>
+    <span>{{ clickMsg }}</span>
 </ion-content>

+ 9 - 0
src/modules/contact/contact-list/contact-list.page.spec.ts

@@ -14,4 +14,13 @@ describe('ContactListPage', () => {
   it('should create', () => {
     expect(component).toBeTruthy();
   });
+
+  it('#clicked() should toggle #isOn', () => {
+    const comp = new ContactListPage();
+    expect(comp.isOn).withContext('off at first').toBe(false);
+    comp.clicked();
+    expect(comp.isOn).withContext('on after click').toBe(true);
+    comp.clicked();
+    expect(comp.isOn).withContext('off after second click').toBe(false);
+  });
 });

+ 8 - 0
src/modules/contact/contact-list/contact-list.page.ts

@@ -70,4 +70,12 @@ export class ContactListPage implements OnInit {
     this.loadContact();
   }
 
+  isOn:boolean = false;
+  clicked(){
+    this.isOn = !this.isOn;
+  }
+  get clickMsg(){
+      return `The light is ${this.isOn ? 'On' : 'Off'}`;
+  }
+
 }