summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/utils
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/utils')
-rw-r--r--vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts40
-rw-r--r--vid-webpack-master/src/app/shared/utils/iframe.service.ts13
2 files changed, 51 insertions, 2 deletions
diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts
new file mode 100644
index 000000000..fd5fe0e65
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts
@@ -0,0 +1,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({});
+ });
+
+});
diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.ts
index 4c699825f..ab93d1ac8 100644
--- a/vid-webpack-master/src/app/shared/utils/iframe.service.ts
+++ b/vid-webpack-master/src/app/shared/utils/iframe.service.ts
@@ -1,22 +1,31 @@
import {Injectable} from "@angular/core";
+import {DialogService} from "ng2-bootstrap-modal";
@Injectable()
export class IframeService {
addClassOpenModal(elementClassName: string) {
- var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
+ const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
if (parentBodyElement) {
parentBodyElement.classList.add("modal-open");
}
}
removeClassCloseModal(elementClassName: string) {
- var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
+ const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
if (parentBodyElement) {
parentBodyElement.classList.remove("modal-open");
}
}
+ closeIframe(dialogService : DialogService, that){
+ this.removeClassCloseModal('content');
+ dialogService.removeDialog(that);
+ setTimeout(() => {
+ window.parent.postMessage("closeIframe", "*");
+ }, 15);
+ }
+
addFullScreen(){
let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0];