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

48 lines
1.5 KiB
JavaScript
Raw 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;
const response = 'foo';
2024-02-16 14:51:54 +00:00
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
$httpBackend.expectRoute('GET', `Workers/${id}`).respond(response);
2020-04-25 09:50:04 +00:00
controller.id = id;
$httpBackend.flush();
expect(controller.worker).toEqual(response);
});
});
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');
}
});
});
});