2019-02-15 11:39:21 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
describe('vnWorkerDescriptor', () => {
|
2019-02-15 11:39:21 +00:00
|
|
|
let controller;
|
2020-04-25 09:50:04 +00:00
|
|
|
let $httpBackend;
|
2019-02-15 11:39:21 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('worker'));
|
2019-02-15 11:39:21 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
2019-02-15 11:39:21 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-04-30 10:48:52 +00:00
|
|
|
controller = $componentController('vnWorkerDescriptor', {$element: null});
|
2020-04-25 09:50:04 +00:00
|
|
|
}));
|
2019-02-15 11:39:21 +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';
|
2019-02-15 11:39:21 +00:00
|
|
|
|
2024-02-16 14:51:54 +00:00
|
|
|
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
|
2020-04-30 10:48:52 +00:00
|
|
|
$httpBackend.expectRoute('GET', `Workers/${id}`).respond(response);
|
2020-04-25 09:50:04 +00:00
|
|
|
controller.id = id;
|
2019-02-15 11:39:21 +00:00
|
|
|
$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');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2019-02-15 11:39:21 +00:00
|
|
|
});
|