1762-worker_dms #31
|
@ -1880,6 +1880,11 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
|
||||||
(104, 2),
|
(104, 2),
|
||||||
(104, 3);
|
(104, 3);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`workerDocument`(`worker`, `document`)
|
||||||
|
VALUES
|
||||||
|
(104, 2),
|
||||||
|
(104, 3);
|
||||||
|
|
||||||
INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`)
|
INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
('aaa', 'android', '9');
|
('aaa', 'android', '9');
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('ClientDms removeFile()', () => {
|
fdescribe('WorkerDms removeFile()', () => {
|
||||||
const clientDmsFk = 3;
|
const workerDmsFk = 1;
|
||||||
it(`should return an error for a user without enough privileges`, async() => {
|
it(`should return an error for a user without enough privileges`, async() => {
|
||||||
let clientId = 101;
|
let clientId = 101;
|
||||||
let ctx = {req: {accessToken: {userId: clientId}}};
|
let ctx = {req: {accessToken: {userId: clientId}}};
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
await app.models.ClientDms.removeFile(ctx, clientDmsFk).catch(e => {
|
await app.models.WorkerDms.removeFile(ctx, workerDmsFk).catch(e => {
|
||||||
error = e;
|
error = e;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
expect(error.message).toEqual(`You don't have enough privileges`);
|
expect(error.message).toEqual(`You don't have enough privileges`);
|
||||||
|
|
|
@ -1,32 +1,34 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
|
||||||
describe('Client', () => {
|
describe('Client', () => {
|
||||||
describe('Component vnClientDmsCreate', () => {
|
describe('Component vnWorkerDmsCreate', () => {
|
||||||
|
let $element;
|
||||||
let controller;
|
let controller;
|
||||||
let $scope;
|
let $scope;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
let $httpParamSerializer;
|
let $httpParamSerializer;
|
||||||
|
|
||||||
beforeEach(ngModule('client'));
|
beforeEach(ngModule('worker'));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
beforeEach(angular.mock.inject(($compile, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpParamSerializer = _$httpParamSerializer_;
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
controller = $componentController('vnClientDmsCreate', {$scope});
|
$element = $compile(`<vn-worker-dms-create></vn-worker-dms-create>`)($rootScope);
|
||||||
controller._client = {id: 101, name: 'Bruce wayne'};
|
controller = $element.controller('vnWorkerDmsCreate');
|
||||||
|
controller._worker = {id: 101, name: 'Bruce wayne'};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('client() setter', () => {
|
describe('worker() setter', () => {
|
||||||
it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller.client = {
|
controller.worker = {
|
||||||
id: 15,
|
id: 15,
|
||||||
name: 'Bruce wayne'
|
name: 'Bruce wayne'
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(controller.client).toBeDefined();
|
expect(controller.worker).toBeDefined();
|
||||||
expect(controller.setDefaultParams).toHaveBeenCalledWith();
|
expect(controller.setDefaultParams).toHaveBeenCalledWith();
|
||||||
expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
|
expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
@ -34,12 +36,12 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('setDefaultParams()', () => {
|
describe('setDefaultParams()', () => {
|
||||||
it('should perform a GET query and define the dms property on controller', () => {
|
it('should perform a GET query and define the dms property on controller', () => {
|
||||||
|
$httpBackend.whenRoute('GET', `DmsTypes`).respond({id: 12, code: 'hhrrData'});
|
||||||
const params = {filter: {
|
const params = {filter: {
|
||||||
where: {code: 'paymentsLaw'}
|
where: {code: 'hhrrData'}
|
||||||
}};
|
}};
|
||||||
let serializedParams = $httpParamSerializer(params);
|
let serializedParams = $httpParamSerializer(params);
|
||||||
$httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'});
|
$httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'hhrrData'});
|
||||||
$httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`);
|
|
||||||
controller.setDefaultParams();
|
controller.setDefaultParams();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
@ -62,8 +64,8 @@ describe('Client', () => {
|
||||||
describe('getAllowedContentTypes()', () => {
|
describe('getAllowedContentTypes()', () => {
|
||||||
it('should make an HTTP GET request to get the allowed content types', () => {
|
it('should make an HTTP GET request to get the allowed content types', () => {
|
||||||
const expectedResponse = ['image/png', 'image/jpg'];
|
const expectedResponse = ['image/png', 'image/jpg'];
|
||||||
$httpBackend.when('GET', `clientDms/allowedContentTypes`).respond(expectedResponse);
|
$httpBackend.when('GET', `workerDms/allowedContentTypes`).respond(expectedResponse);
|
||||||
$httpBackend.expect('GET', `clientDms/allowedContentTypes`);
|
$httpBackend.expect('GET', `workerDms/allowedContentTypes`);
|
||||||
controller.getAllowedContentTypes();
|
controller.getAllowedContentTypes();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue