salix/front/core/components/spinner/spinner.spec.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-10-13 15:35:47 +00:00
import './spinner.js';
describe('Component vnSpinner', () => {
let $element;
let controller;
2017-10-13 15:35:47 +00:00
beforeEach(ngModule('vnCore'));
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
});
});
});