48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import './index.js';
|
|
|
|
describe('vnWorkerDescriptor', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
|
|
beforeEach(ngModule('worker'));
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
controller = $componentController('vnWorkerDescriptor', {$element: null});
|
|
}));
|
|
|
|
describe('loadData()', () => {
|
|
it(`should perform a get query to store the worker data into the controller`, () => {
|
|
const id = 1;
|
|
const response = ['foo'];
|
|
|
|
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
|
|
$httpBackend.expectRoute('GET', `Workers/summary`).respond(response);
|
|
controller.id = id;
|
|
$httpBackend.flush();
|
|
|
|
expect([controller.worker]).toEqual(response);
|
|
});
|
|
});
|
|
|
|
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');
|
|
}
|
|
});
|
|
});
|
|
});
|