fixed dms unit tests

This commit is contained in:
Joan Sanchez 2019-07-16 14:12:58 +02:00
parent 5e40b384ff
commit 87e0a914ad
9 changed files with 27 additions and 27 deletions

View File

@ -34,7 +34,7 @@ module.exports = Self => {
type: 'Boolean', type: 'Boolean',
description: 'True if has original file' description: 'True if has original file'
}, { }, {
arg: 'hasAttachedFile', arg: 'hasFileAttached',
type: 'Boolean', type: 'Boolean',
description: 'True if has an attached file' description: 'True if has an attached file'
}], }],
@ -49,7 +49,7 @@ module.exports = Self => {
}); });
Self.updateFile = async(ctx, id, warehouseId, companyId, Self.updateFile = async(ctx, id, warehouseId, companyId,
dmsTypeId, reference, description, hasFile, hasAttachedFile, options) => { dmsTypeId, reference, description, hasFile, hasFileAttached, options) => {
const models = Self.app.models; const models = Self.app.models;
let tx; let tx;
@ -78,7 +78,7 @@ module.exports = Self => {
hasFile: hasFile hasFile: hasFile
}, myOptions); }, myOptions);
if (hasAttachedFile) if (hasFileAttached)
await uploadNewFile(ctx, dms, myOptions); await uploadNewFile(ctx, dms, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -11,7 +11,7 @@ class Controller {
this.dms = { this.dms = {
files: [], files: [],
hasFile: false, hasFile: false,
hasAttachedFile: false hasFileAttached: false
}; };
} }
@ -79,12 +79,12 @@ class Controller {
} }
onFileChange(files) { onFileChange(files) {
let hasAttachedFile = false; let hasFileAttached = false;
if (files.length > 0) if (files.length > 0)
hasAttachedFile = true; hasFileAttached = true;
this.$.$applyAsync(() => { this.$.$applyAsync(() => {
this.dms.hasAttachedFile = hasAttachedFile; this.dms.hasFileAttached = hasFileAttached;
}); });
} }
} }

View File

@ -48,12 +48,12 @@ describe('Client', () => {
}); });
describe('onFileChange()', () => { describe('onFileChange()', () => {
it('should set dms hasFile property to true if has any files', () => { it('should set dms hasFileAttached property to true if has any files', () => {
const files = [{id: 1, name: 'MyFile'}]; const files = [{id: 1, name: 'MyFile'}];
controller.onFileChange(files); controller.onFileChange(files);
$scope.$apply(); $scope.$apply();
expect(controller.dms.hasFile).toBeTruthy(); expect(controller.dms.hasFileAttached).toBeTruthy();
}); });
}); });
}); });

View File

@ -33,7 +33,7 @@ class Controller {
dmsTypeId: dms.dmsTypeFk, dmsTypeId: dms.dmsTypeFk,
description: dms.description, description: dms.description,
hasFile: dms.hasFile, hasFile: dms.hasFile,
hasAttachedFile: false, hasFileAttached: false,
files: [] files: []
}; };
}); });
@ -68,12 +68,12 @@ class Controller {
} }
onFileChange(files) { onFileChange(files) {
let hasAttachedFile = false; let hasFileAttached = false;
if (files.length > 0) if (files.length > 0)
hasAttachedFile = true; hasFileAttached = true;
this.$.$applyAsync(() => { this.$.$applyAsync(() => {
this.dms.hasAttachedFile = hasAttachedFile; this.dms.hasFileAttached = hasFileAttached;
}); });
} }
} }

View File

@ -48,12 +48,12 @@ describe('Client', () => {
}); });
describe('onFileChange()', () => { describe('onFileChange()', () => {
it('should set dms hasFile property to true if has any files', () => { it('should set dms hasFileAttached property to true if has any files', () => {
const files = [{id: 1, name: 'MyFile'}]; const files = [{id: 1, name: 'MyFile'}];
controller.onFileChange(files); controller.onFileChange(files);
$scope.$apply(); $scope.$apply();
expect(controller.dms.hasFile).toBeTruthy(); expect(controller.dms.hasFileAttached).toBeTruthy();
}); });
}); });
}); });

View File

@ -11,7 +11,7 @@ class Controller {
this.dms = { this.dms = {
files: [], files: [],
hasFile: false, hasFile: false,
hasAttachedFile: false hasFileAttached: false
}; };
} }
@ -77,12 +77,12 @@ class Controller {
} }
onFileChange(files) { onFileChange(files) {
let hasAttachedFile = false; let hasFileAttached = false;
if (files.length > 0) if (files.length > 0)
hasAttachedFile = true; hasFileAttached = true;
this.$.$applyAsync(() => { this.$.$applyAsync(() => {
this.dms.hasAttachedFile = hasAttachedFile; this.dms.hasFileAttached = hasFileAttached;
}); });
} }
} }

View File

@ -53,12 +53,12 @@ describe('Ticket', () => {
}); });
describe('onFileChange()', () => { describe('onFileChange()', () => {
it('should set dms hasFile property to true if has any files', () => { it('should set dms hasFileAttached property to true if has any files', () => {
const files = [{id: 1, name: 'MyFile'}]; const files = [{id: 1, name: 'MyFile'}];
controller.onFileChange(files); controller.onFileChange(files);
$scope.$apply(); $scope.$apply();
expect(controller.dms.hasFile).toBeTruthy(); expect(controller.dms.hasFileAttached).toBeTruthy();
}); });
}); });
}); });

View File

@ -33,7 +33,7 @@ class Controller {
dmsTypeId: dms.dmsTypeFk, dmsTypeId: dms.dmsTypeFk,
description: dms.description, description: dms.description,
hasFile: dms.hasFile, hasFile: dms.hasFile,
hasAttachedFile: false, hasFileAttached: false,
files: [] files: []
}; };
}); });
@ -68,12 +68,12 @@ class Controller {
} }
onFileChange(files) { onFileChange(files) {
let hasAttachedFile = false; let hasFileAttached = false;
if (files.length > 0) if (files.length > 0)
hasAttachedFile = true; hasFileAttached = true;
this.$.$applyAsync(() => { this.$.$applyAsync(() => {
this.dms.hasAttachedFile = hasAttachedFile; this.dms.hasFileAttached = hasFileAttached;
}); });
} }
} }

View File

@ -48,12 +48,12 @@ describe('Client', () => {
}); });
describe('onFileChange()', () => { describe('onFileChange()', () => {
it('should set dms hasFile property to true if has any files', () => { it('should set dms hasFileAttached property to true if has any files', () => {
const files = [{id: 1, name: 'MyFile'}]; const files = [{id: 1, name: 'MyFile'}];
controller.onFileChange(files); controller.onFileChange(files);
$scope.$apply(); $scope.$apply();
expect(controller.dms.hasFile).toBeTruthy(); expect(controller.dms.hasFileAttached).toBeTruthy();
}); });
}); });
}); });