97732 Fix flaky test for ContextHelpToggleComponent

This commit is contained in:
Koen Pauwels
2023-01-16 14:13:01 +01:00
parent bed14c6b06
commit e5cc565327

View File

@@ -13,8 +13,9 @@ describe('ContextHelpToggleComponent', () => {
const contextHelpEmpty$ = new BehaviorSubject(true); const contextHelpEmpty$ = new BehaviorSubject(true);
beforeEach(async () => { beforeEach(async () => {
contextHelpService = jasmine.createSpyObj('contextHelpService', contextHelpService = jasmine.createSpyObj('contextHelpService', [
['toggleIcons', 'contextHelpEmpty$']); 'contextHelpEmpty$', 'toggleIcons'
]);
contextHelpService.contextHelpEmpty$.and.returnValue(contextHelpEmpty$); contextHelpService.contextHelpEmpty$.and.returnValue(contextHelpEmpty$);
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ ContextHelpToggleComponent ], declarations: [ ContextHelpToggleComponent ],
@@ -44,6 +45,7 @@ describe('ContextHelpToggleComponent', () => {
it('clicking the button should toggle context help icon visibility', () => { it('clicking the button should toggle context help icon visibility', () => {
fixture.whenStable().then((done) => { fixture.whenStable().then((done) => {
spyOn(contextHelpService, 'toggleIcons');
fixture.debugElement.query(By.css('a')).nativeElement.click(); fixture.debugElement.query(By.css('a')).nativeElement.click();
expect(contextHelpService.toggleIcons).toHaveBeenCalled(); expect(contextHelpService.toggleIcons).toHaveBeenCalled();
done(); done();
@@ -54,6 +56,7 @@ describe('ContextHelpToggleComponent', () => {
describe('if there are no elements on the page with a tooltip', () => { describe('if there are no elements on the page with a tooltip', () => {
it('clicking the button does not toggle context help icon visibility', () => { it('clicking the button does not toggle context help icon visibility', () => {
fixture.whenStable().then((done) => { fixture.whenStable().then((done) => {
spyOn(contextHelpService, 'toggleIcons');
fixture.debugElement.query(By.css('a')).nativeElement.click(); fixture.debugElement.query(By.css('a')).nativeElement.click();
expect(contextHelpService.toggleIcons).toHaveBeenCalledTimes(0); expect(contextHelpService.toggleIcons).toHaveBeenCalledTimes(0);
done(); done();