-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Added unit tests for the cc merchant info (#3372)
- Loading branch information
1 parent
4668e12
commit 54d686d
Showing
3 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 41 additions & 7 deletions
48
...nents/cc-expense-merchant-info-popover/cc-expense-merchant-info-popover.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,58 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
import { IonicModule, PopoverController } from '@ionic/angular'; | ||
|
||
import { CcExpenseMerchantInfoPopoverComponent } from './cc-expense-merchant-info-popover.component'; | ||
import { CCExpenseMerchantInfoPopoverComponent } from './cc-expense-merchant-info-popover.component'; | ||
import { getElementBySelector } from 'src/app/core/dom-helpers'; | ||
|
||
describe('CcExpenseMerchantInfoComponent', () => { | ||
let component: CcExpenseMerchantInfoPopoverComponent; | ||
let fixture: ComponentFixture<CcExpenseMerchantInfoPopoverComponent>; | ||
describe('CCExpenseMerchantInfoComponent', () => { | ||
let component: CCExpenseMerchantInfoPopoverComponent; | ||
let popoverController: jasmine.SpyObj<PopoverController>; | ||
let fixture: ComponentFixture<CCExpenseMerchantInfoPopoverComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
const popoverControllerSpy = jasmine.createSpyObj('PopoverController', ['dismiss']); | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [CcExpenseMerchantInfoPopoverComponent], | ||
declarations: [CCExpenseMerchantInfoPopoverComponent], | ||
imports: [IonicModule.forRoot()], | ||
providers: [ | ||
{ | ||
provide: PopoverController, | ||
useValue: popoverControllerSpy, | ||
}, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(CcExpenseMerchantInfoPopoverComponent); | ||
fixture = TestBed.createComponent(CCExpenseMerchantInfoPopoverComponent); | ||
popoverController = TestBed.inject(PopoverController) as jasmine.SpyObj<PopoverController>; | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should close the popover when clicked on close button', () => { | ||
const closeBtn = getElementBySelector(fixture, '[data-testid="close-btn"') as HTMLButtonElement; | ||
closeBtn.click(); | ||
|
||
fixture.detectChanges(); | ||
|
||
expect(popoverController.dismiss).toHaveBeenCalled(); | ||
}); | ||
|
||
describe('template', () => { | ||
it('should display the correct title', () => { | ||
fixture.detectChanges(); | ||
const title = getElementBySelector(fixture, '[data-testid="title"'); | ||
expect(title.textContent).toEqual('Merchant'); | ||
}); | ||
|
||
it('should display the correct content', () => { | ||
fixture.detectChanges(); | ||
const content = getElementBySelector(fixture, '[data-testid="content"'); | ||
expect(content.textContent).toEqual('This merchant name comes from the transaction.'); | ||
}); | ||
}); | ||
}); |