2018-08-31 11:06:39 +00:00
|
|
|
describe('factory vnModuleLoader', () => {
|
|
|
|
let vnModuleLoader;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2018-08-31 11:06:39 +00:00
|
|
|
|
2019-01-26 01:30:46 +00:00
|
|
|
beforeEach(angular.mock.inject((_vnModuleLoader_, $rootScope, $window) => {
|
2018-08-31 11:06:39 +00:00
|
|
|
vnModuleLoader = _vnModuleLoader_;
|
2019-01-26 01:30:46 +00:00
|
|
|
$window.routes = [{module: 'myModule'}];
|
2018-08-31 11:06:39 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('load()', () => {
|
|
|
|
it('should return truthy promise if the module was loaded', async() => {
|
|
|
|
vnModuleLoader._loaded.myModule = true;
|
|
|
|
|
|
|
|
let result = await vnModuleLoader.load('myModule', {myValidations: () => {}});
|
|
|
|
|
|
|
|
expect(result).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a promise if the module was still a promise', () => {
|
|
|
|
vnModuleLoader._loaded.myModule = new Promise(() => {
|
|
|
|
return 'I promise you a module!';
|
|
|
|
});
|
|
|
|
|
|
|
|
let result = vnModuleLoader.load('myModule', {myValidations: () => {}});
|
|
|
|
|
|
|
|
expect(result).toEqual(jasmine.any(Promise));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|