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-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2017-10-13 15:35:47 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($compile, $rootScope) => {
|
2019-10-18 19:36:30 +00:00
|
|
|
$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`, () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller, 'start');
|
2017-10-13 15:35:47 +00:00
|
|
|
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`, () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller, 'stop');
|
2017-10-13 15:35:47 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|