From fceee0a9d66baa0ec4db1bf5b041e5ba955874a5 Mon Sep 17 00:00:00 2001 From: Ainki Date: Thu, 26 Mar 2020 19:10:09 +0100 Subject: [PATCH] spec --- back/methods/collection/getSectors.js | 6 +++--- back/methods/collection/spec/collectionFauls.spec.js | 8 ++++++++ back/methods/collection/spec/getCollection.spec.js | 10 ++++++++++ back/methods/collection/spec/getSectors.spec.js | 9 +++++++++ back/methods/collection/spec/newCollection.spec.js | 10 ++++++++++ .../collection/spec/updateCollectionSale.spec.js | 7 +++++++ 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 back/methods/collection/spec/collectionFauls.spec.js create mode 100644 back/methods/collection/spec/getCollection.spec.js create mode 100644 back/methods/collection/spec/getSectors.spec.js create mode 100644 back/methods/collection/spec/newCollection.spec.js create mode 100644 back/methods/collection/spec/updateCollectionSale.spec.js diff --git a/back/methods/collection/getSectors.js b/back/methods/collection/getSectors.js index d844e5097..12ad0dc06 100644 --- a/back/methods/collection/getSectors.js +++ b/back/methods/collection/getSectors.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('getSectors', { + Self.remoteMethod('getSectors', { description: 'Get all sectors', accessType: 'READ', returns: { @@ -12,9 +12,9 @@ module.exports = Self => { } }); - Self.getSectors = async ctx => { + Self.getSectors = async() => { const query = `CALL vn.sector_get()`; - const [result] = await Self.rawSql(query, []); + const [result] = await Self.rawSql(query); return result; }; }; diff --git a/back/methods/collection/spec/collectionFauls.spec.js b/back/methods/collection/spec/collectionFauls.spec.js new file mode 100644 index 000000000..0df234bfd --- /dev/null +++ b/back/methods/collection/spec/collectionFauls.spec.js @@ -0,0 +1,8 @@ + +describe('collectionFaults()', () => { + it('return shelving afected', async() => { + let val = 2; + + expect(val).toBeGreaterThan(1); + }); +}); diff --git a/back/methods/collection/spec/getCollection.spec.js b/back/methods/collection/spec/getCollection.spec.js new file mode 100644 index 000000000..b8a92285f --- /dev/null +++ b/back/methods/collection/spec/getCollection.spec.js @@ -0,0 +1,10 @@ +const app = require('vn-loopback/server/server'); + +describe('getCollection()', () => { + it('return list of collection', async() => { + let ctx = {req: {accessToken: {userId: 1}}}; + let response = await app.models.Collection.getCollection(ctx); + + expect(response.length).toEqual(0); + }); +}); diff --git a/back/methods/collection/spec/getSectors.spec.js b/back/methods/collection/spec/getSectors.spec.js new file mode 100644 index 000000000..4ba288c01 --- /dev/null +++ b/back/methods/collection/spec/getSectors.spec.js @@ -0,0 +1,9 @@ +const app = require('vn-loopback/server/server'); + +describe('getSectors()', () => { + it('return list of sectors', async() => { + let response = await app.models.Collection.getSectors(); + + expect(response.length).toBeGreaterThan(0); + }); +}); diff --git a/back/methods/collection/spec/newCollection.spec.js b/back/methods/collection/spec/newCollection.spec.js new file mode 100644 index 000000000..4bf3f7945 --- /dev/null +++ b/back/methods/collection/spec/newCollection.spec.js @@ -0,0 +1,10 @@ +const app = require('vn-loopback/server/server'); + +describe('newCollection()', () => { + it('return a new collection', async() => { + let ctx = {req: {accessToken: {userId: 1}}}; + let response = await app.models.Collection.newCollection(ctx, 500, 1, 1); + + expect(response.length).toBeGreaterThan(0); + }); +}); diff --git a/back/methods/collection/spec/updateCollectionSale.spec.js b/back/methods/collection/spec/updateCollectionSale.spec.js new file mode 100644 index 000000000..bd4d0fb78 --- /dev/null +++ b/back/methods/collection/spec/updateCollectionSale.spec.js @@ -0,0 +1,7 @@ +describe('updateCollectionSale()', () => { + it('return a collection updated', async() => { + let val = 2; + + expect(val).toBeGreaterThan(1); + }); +});