2017-10-13 15:35:47 +00:00
|
|
|
import './spinner.js';
|
|
|
|
|
|
|
|
describe('Component vnSpinner', () => {
|
|
|
|
let $element;
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2017-10-13 15:35:47 +00:00
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('vnCore', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2017-10-13 15:35:47 +00:00
|
|
|
|
2019-10-18 19:36:30 +00:00
|
|
|
beforeEach(angular.mock.inject(($compile, $rootScope) => {
|
|
|
|
$element = $compile(`<vn-spinner></vn-spinner>`)($rootScope);
|
|
|
|
controller = $element.controller('vnSpinner');
|
2017-10-13 15:35:47 +00:00
|
|
|
}));
|
|
|
|
|
2019-10-18 19:36:30 +00:00
|
|
|
afterEach(() => {
|
|
|
|
$element.remove();
|
|
|
|
});
|
|
|
|
|
2017-10-13 15:35:47 +00:00
|
|
|
describe('enable()', () => {
|
2019-10-18 19:36:30 +00:00
|
|
|
it(`should call start() when enable is set to true`, () => {
|
2017-10-13 15:35:47 +00:00
|
|
|
spyOn(controller, 'start');
|
|
|
|
controller.enable = true;
|
|
|
|
|
|
|
|
expect(controller.start).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
|
2019-10-18 19:36:30 +00:00
|
|
|
it(`should call stop() when enable is set to false`, () => {
|
2017-10-13 15:35:47 +00:00
|
|
|
spyOn(controller, 'stop');
|
|
|
|
controller.enable = false;
|
|
|
|
|
|
|
|
expect(controller.stop).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('start()', () => {
|
2019-10-18 19:36:30 +00:00
|
|
|
it(`should set enable to true`, () => {
|
2017-10-13 15:35:47 +00:00
|
|
|
controller.start();
|
|
|
|
|
2019-10-18 19:36:30 +00:00
|
|
|
expect(controller.enable).toBeTruthy();
|
2017-10-13 15:35:47 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('stop()', () => {
|
2019-10-18 19:36:30 +00:00
|
|
|
it(`should set enable to false`, () => {
|
2017-10-13 15:35:47 +00:00
|
|
|
controller.stop();
|
|
|
|
|
2019-10-18 19:36:30 +00:00
|
|
|
expect(controller.enable).toBeFalsy();
|
2017-10-13 15:35:47 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|