summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts
blob: fd5fe0e65cc9140907917fbb0cb1f29b0e0855e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {getTestBed, TestBed} from "@angular/core/testing";
import {IframeService} from "./iframe.service";
import {DialogService} from "ng2-bootstrap-modal";

export class DialogServiceMock extends DialogService {
  removeDialog: (that) => ({})
}

describe('Iframe service', () => {
  let injector;
  let service: IframeService;
  beforeAll(done => (async () => {
    TestBed.configureTestingModule({
      providers : [
        IframeService
      ]
    });
    await TestBed.compileComponents();

    injector = getTestBed();
    service = injector.get(IframeService);

  })().then(done).catch(done.fail));


  test('service should be defined', ()=>{
    expect(service).toBeDefined();
  });

  test('closeIframe: should call removeClassCloseModal', ()=>{
    const dialogService = new DialogServiceMock(null, null, null, null);
    spyOn(service, 'removeClassCloseModal');
    spyOn(dialogService, 'removeDialog');
    service.closeIframe(dialogService, {})

    expect(service.removeClassCloseModal).toBeCalledWith('content');
    expect(dialogService.removeDialog).toBeCalledWith({});
  });

});