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

47 lines
1.4 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';
$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');
}
});
});
});