Refactor back-end unit test + helpers
This commit is contained in:
parent
808ff40794
commit
f95a2f646b
|
@ -14,5 +14,6 @@ export default {
|
||||||
vnAutocomplete: 'vn-autocomplete',
|
vnAutocomplete: 'vn-autocomplete',
|
||||||
vnCheck: 'vn-check',
|
vnCheck: 'vn-check',
|
||||||
vnIconButton: 'vn-icon-button',
|
vnIconButton: 'vn-icon-button',
|
||||||
vnItemSummary: 'vn-item-summary > vn-card > div > vn-vertical'
|
vnItemSummary: 'vn-item-summary > vn-card > div > vn-vertical',
|
||||||
|
vnLabelValue: 'vn-label-value'
|
||||||
};
|
};
|
||||||
|
|
|
@ -264,11 +264,11 @@ export default {
|
||||||
submitBotanicalButton: `${components.vnSubmit}`
|
submitBotanicalButton: `${components.vnSubmit}`
|
||||||
},
|
},
|
||||||
itemSummary: {
|
itemSummary: {
|
||||||
basicData: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(2) > vn-vertical > p:nth-child(2)`,
|
basicData: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(2) > vn-vertical`,
|
||||||
vat: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(3) > vn-vertical > p`,
|
vat: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(3) > vn-vertical > p`,
|
||||||
tags: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > p`,
|
tags: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-vertical:nth-child(1) > vn-label-value:nth-child(2)`,
|
||||||
niche: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(2) > vn-vertical > p:nth-child(2)`,
|
niche: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(2) > vn-vertical > vn-label-value:nth-child(2)`,
|
||||||
botanical: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(3) > vn-vertical > p`,
|
botanical: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(3) > vn-vertical > vn-label-value:nth-child(2)`,
|
||||||
barcode: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(4) > vn-vertical > p`
|
barcode: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(4) > vn-vertical > p`
|
||||||
},
|
},
|
||||||
ticketsIndex: {
|
ticketsIndex: {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const getAverageInvoiced = require('../getAverageInvoiced');
|
const getAverageInvoiced = require('../getAverageInvoiced');
|
||||||
const {rawSql} = require('./helpers');
|
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||||
const model = {
|
const model = {
|
||||||
remoteMethod: () => {}
|
remoteMethod: () => {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const getMana = require('../getMana');
|
const getMana = require('../getMana');
|
||||||
const {rawSql} = require('./helpers');
|
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||||
const model = {
|
const model = {
|
||||||
remoteMethod: () => {}
|
remoteMethod: () => {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
const getVolume = require('../get-volume');
|
const getVolume = require('../get-volume');
|
||||||
|
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||||
|
const model = {
|
||||||
|
remoteMethod: () => {}
|
||||||
|
};
|
||||||
|
|
||||||
describe('client getVolume()', () => {
|
rawSql(model);
|
||||||
|
getVolume(model);
|
||||||
|
|
||||||
|
describe('ticket getVolume()', () => {
|
||||||
it('should call the getVolume method', done => {
|
it('should call the getVolume method', done => {
|
||||||
let ticketFk = 1;
|
let ticketFk = 1;
|
||||||
let self = jasmine.createSpyObj('self', ['remoteMethod', 'rawSql']);
|
model.getVolume(ticketFk)
|
||||||
self.rawSql.and.returnValue(Promise.resolve([{volumeData: 100}]));
|
.then(response => {
|
||||||
getVolume(self);
|
expect(response[0][0].m3_total).toEqual(0.008);
|
||||||
|
|
||||||
self.getVolume(ticketFk)
|
|
||||||
.then(result => {
|
|
||||||
expect(result).toEqual([{volumeData: 100}]);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports.rawSql = Self => {
|
module.exports.rawSql = Self => {
|
||||||
const DataSource = require('loopback-datasource-juggler').DataSource;
|
const DataSource = require('loopback-datasource-juggler').DataSource;
|
||||||
const rawSql = require('../../../../common/methods/vnModel/rawSql.js');
|
const rawSql = require('../methods/vnModel/rawSql.js');
|
||||||
const dataSourceConfig = {
|
const dataSourceConfig = {
|
||||||
connector: 'mysql',
|
connector: 'mysql',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
Loading…
Reference in New Issue