Refactor back-end unit test + helpers
This commit is contained in:
parent
808ff40794
commit
f95a2f646b
|
@ -14,5 +14,6 @@ export default {
|
|||
vnAutocomplete: 'vn-autocomplete',
|
||||
vnCheck: 'vn-check',
|
||||
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}`
|
||||
},
|
||||
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`,
|
||||
tags: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > p`,
|
||||
niche: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(2) > vn-vertical > p:nth-child(2)`,
|
||||
botanical: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(3) > vn-vertical > 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 > vn-label-value:nth-child(2)`,
|
||||
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`
|
||||
},
|
||||
ticketsIndex: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const getAverageInvoiced = require('../getAverageInvoiced');
|
||||
const {rawSql} = require('./helpers');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const getMana = require('../getMana');
|
||||
const {rawSql} = require('./helpers');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
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 => {
|
||||
let ticketFk = 1;
|
||||
let self = jasmine.createSpyObj('self', ['remoteMethod', 'rawSql']);
|
||||
self.rawSql.and.returnValue(Promise.resolve([{volumeData: 100}]));
|
||||
getVolume(self);
|
||||
|
||||
self.getVolume(ticketFk)
|
||||
.then(result => {
|
||||
expect(result).toEqual([{volumeData: 100}]);
|
||||
model.getVolume(ticketFk)
|
||||
.then(response => {
|
||||
expect(response[0][0].m3_total).toEqual(0.008);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports.rawSql = Self => {
|
||||
const DataSource = require('loopback-datasource-juggler').DataSource;
|
||||
const rawSql = require('../../../../common/methods/vnModel/rawSql.js');
|
||||
const rawSql = require('../methods/vnModel/rawSql.js');
|
||||
const dataSourceConfig = {
|
||||
connector: 'mysql',
|
||||
host: 'localhost',
|
Loading…
Reference in New Issue