33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
describe('factory vnModuleLoader', () => {
|
|
let vnModuleLoader;
|
|
|
|
beforeEach(angular.mock.module('vnCore', $translateProvider => {
|
|
$translateProvider.translations('en', {});
|
|
}));
|
|
|
|
beforeEach(angular.mock.inject((_vnModuleLoader_, $rootScope, $window) => {
|
|
vnModuleLoader = _vnModuleLoader_;
|
|
$window.routes = [{module: 'myModule'}];
|
|
}));
|
|
|
|
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));
|
|
});
|
|
});
|
|
});
|