Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 1 | import {getTestBed, TestBed} from "@angular/core/testing"; |
| 2 | import {IframeService} from "./iframe.service"; |
| 3 | import {DialogService} from "ng2-bootstrap-modal"; |
| 4 | |
| 5 | export class DialogServiceMock extends DialogService { |
| 6 | removeDialog: (that) => ({}) |
| 7 | } |
| 8 | |
| 9 | describe('Iframe service', () => { |
| 10 | let injector; |
| 11 | let service: IframeService; |
| 12 | beforeAll(done => (async () => { |
| 13 | TestBed.configureTestingModule({ |
| 14 | providers : [ |
| 15 | IframeService |
| 16 | ] |
| 17 | }); |
| 18 | await TestBed.compileComponents(); |
| 19 | |
| 20 | injector = getTestBed(); |
| 21 | service = injector.get(IframeService); |
| 22 | |
| 23 | })().then(done).catch(done.fail)); |
| 24 | |
| 25 | |
| 26 | test('service should be defined', ()=>{ |
| 27 | expect(service).toBeDefined(); |
| 28 | }); |
| 29 | |
| 30 | test('closeIframe: should call removeClassCloseModal', ()=>{ |
| 31 | const dialogService = new DialogServiceMock(null, null, null, null); |
| 32 | spyOn(service, 'removeClassCloseModal'); |
| 33 | spyOn(dialogService, 'removeDialog'); |
| 34 | service.closeIframe(dialogService, {}) |
| 35 | |
| 36 | expect(service.removeClassCloseModal).toBeCalledWith('content'); |
| 37 | expect(dialogService.removeDialog).toBeCalledWith({}); |
| 38 | }); |
| 39 | |
| 40 | }); |