From 72e8a686f62344f11c0deb6015cfc0ece4b02b46 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 14 May 2020 10:15:24 +0300 Subject: [PATCH] test: add else case for listenToEscape call spec --- .../lib/tests/confirmation.service.spec.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts index 1413e034d7..3cbdcbd7de 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts @@ -106,13 +106,20 @@ describe('ConfirmationService', () => { selectConfirmationElement('button#cancel').click(); }); - test('should not call the listenToEscape method when dismissible is false', () => { - const spy = spyOn(service as any, 'listenToEscape'); - - service.info('', '', { dismissible: false }); - - expect(spy.calls.count()).toBe(0); - }); + test.each` + dismissible | count + ${true} | ${1} + ${false} | ${0} + `( + 'should call the listenToEscape method $count times when dismissible is $dismissible', + ({ dismissible, count }) => { + const spy = spyOn(service as any, 'listenToEscape'); + + service.info('', '', { dismissible }); + + expect(spy).toHaveBeenCalledTimes(count); + }, + ); }); function clearElements(selector = '.confirmation') {