salix/modules/worker/front/descriptor/index.spec.js

48 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

import './index.js';
describe('vnWorkerDescriptor', () => {
let controller;
2020-04-25 09:50:04 +00:00
let $httpBackend;
beforeEach(ngModule('worker'));
2020-04-25 09:50:04 +00:00
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnWorkerDescriptor', {$element: null});
2020-04-25 09:50:04 +00:00
}));
describe('loadData()', () => {
it(`should perform a get query to store the worker data into the controller`, () => {
2020-04-25 09:50:04 +00:00
const id = 1;
2024-09-06 14:09:29 +00:00
const response = ['foo'];
2024-02-16 14:51:54 +00:00
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
2024-09-06 14:04:40 +00:00
$httpBackend.expectRoute('GET', 'Workers/descriptor').respond(response);
2020-04-25 09:50:04 +00:00
controller.id = id;
$httpBackend.flush();
2024-09-06 14:09:29 +00:00
expect(controller.worker).toEqual(response[0]);
});
});
2023-10-16 13:58:25 +00:00
describe('setPassword()', () => {
it('should throw an error: You must enter a new password', () => {
try {
controller.setPassword();
} catch (error) {
expect(error.message).toEqual('You must enter a new password');
}
});
it('should throw an error: Passwords don\'t match', () => {
controller.newPassword = 'aaa';
controller.repeatPassword = 'bbb';
try {
controller.setPassword();
} catch (error) {
expect(error.message).toEqual('Passwords don\'t match');
}
});
});
});