From feb80006abce1b70061ee2b03197c463f9515e15 Mon Sep 17 00:00:00 2001 From: gerard Date: Wed, 8 Aug 2018 16:15:53 +0200 Subject: [PATCH] Tarea #562 /order/getVolumes.js --- services/order/common/methods/order/getVolumes.js | 4 ++-- .../order/common/methods/order/specs/getVolumes.spec.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 services/order/common/methods/order/specs/getVolumes.spec.js diff --git a/services/order/common/methods/order/getVolumes.js b/services/order/common/methods/order/getVolumes.js index f7583f425..de3f87912 100644 --- a/services/order/common/methods/order/getVolumes.js +++ b/services/order/common/methods/order/getVolumes.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getVolume', { + Self.remoteMethod('getVolumes', { description: 'Returns the volumes of a order', accessType: 'READ', accepts: [{ @@ -18,7 +18,7 @@ module.exports = Self => { } }); - Self.getVolume = async orderFk => { + Self.getVolumes = async orderFk => { let [volume] = await Self.rawSql(`CALL vn.orderListVolume(?)`, [orderFk]); return volume; }; diff --git a/services/order/common/methods/order/specs/getVolumes.spec.js b/services/order/common/methods/order/specs/getVolumes.spec.js new file mode 100644 index 000000000..39f9eaa49 --- /dev/null +++ b/services/order/common/methods/order/specs/getVolumes.spec.js @@ -0,0 +1,9 @@ +const app = require(`../../../../server/server`); + +describe('order getVolumes()', () => { + it('should return the volumes of a given order id', async() => { + let [result] = await app.models.Order.getVolumes(1); + + expect(result.volume).toEqual(0.072); + }); +});