From 9928521557e5fbae8c7d8e8d91bf500b566cbe84 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 13 Apr 2018 18:32:20 +0200 Subject: [PATCH] #235 getMana back unit test plus helpers setup --- .../methods/client/specs/getMana.spec.js | 19 +++++++++++++++++++ .../common/methods/client/specs/helpers.js | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 services/loopback/common/methods/client/specs/getMana.spec.js create mode 100644 services/loopback/common/methods/client/specs/helpers.js diff --git a/services/loopback/common/methods/client/specs/getMana.spec.js b/services/loopback/common/methods/client/specs/getMana.spec.js new file mode 100644 index 000000000..f9b634c62 --- /dev/null +++ b/services/loopback/common/methods/client/specs/getMana.spec.js @@ -0,0 +1,19 @@ +const getMana = require('../getMana'); +const {rawSql} = require('./helpers'); +const model = { + remoteMethod: () => {} +}; + +rawSql(model); +getMana(model); + +describe('client getMana()', () => { + it('should call the getMana method', done => { + model.getMana(101) + .then(response => { + expect(response.mana).toEqual(0); + done(); + }); + }); +}); + diff --git a/services/loopback/common/methods/client/specs/helpers.js b/services/loopback/common/methods/client/specs/helpers.js new file mode 100644 index 000000000..56034b206 --- /dev/null +++ b/services/loopback/common/methods/client/specs/helpers.js @@ -0,0 +1,14 @@ +module.exports.rawSql = Self => { + const DataSource = require('loopback-datasource-juggler').DataSource; + const rawSql = require('../../../../common/methods/vnModel/rawSql.js'); + const dataSourceConfig = { + connector: 'mysql', + host: 'localhost', + user: 'root', + password: 'root', + database: 'salix' + }; + const dataSource = new DataSource(dataSourceConfig); + Self.dataSource = dataSource; + rawSql(Self); +};