mirror of https://github.com/Squidex/squidex.git
5 changed files with 86 additions and 6 deletions
@ -0,0 +1,25 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Sebastian Stehle. All rights reserved |
|||
*/ |
|||
|
|||
import { RootViewDirective } from './../'; |
|||
|
|||
describe('RootViewDirective', () => { |
|||
it('should call init of service in ctor', () => { |
|||
let viewRef = {}; |
|||
let viewRefPassed = null; |
|||
|
|||
const service = { |
|||
init: (ref: any) => { |
|||
viewRefPassed = ref; |
|||
} |
|||
}; |
|||
|
|||
new RootViewDirective(<any>viewRef, <any>service); |
|||
|
|||
expect(viewRef).toBe(viewRefPassed); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,43 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Sebastian Stehle. All rights reserved |
|||
*/ |
|||
|
|||
import { RootViewService } from './../'; |
|||
|
|||
describe('RootViewService', () => { |
|||
const rootViewService = new RootViewService(); |
|||
|
|||
it('should call view when clearing element', () => { |
|||
let isClearCalled = false; |
|||
|
|||
const viewRef = { |
|||
clear: () => { |
|||
isClearCalled = true; |
|||
} |
|||
}; |
|||
|
|||
rootViewService.init(<any>viewRef); |
|||
rootViewService.clear(); |
|||
|
|||
expect(isClearCalled).toBeTruthy(); |
|||
}); |
|||
|
|||
it('should call view when creating element', () => { |
|||
let view = {}; |
|||
|
|||
const viewRef = { |
|||
createEmbeddedView: () => { |
|||
return view; |
|||
} |
|||
}; |
|||
|
|||
rootViewService.init(<any>viewRef); |
|||
|
|||
const result = rootViewService.createEmbeddedView(<any>{}); |
|||
|
|||
expect(result).toBe(view); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue