From 215ae09b70a2089476a914ffee9bf60cd7ac32d6 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 31 Jan 2018 11:15:12 +0100 Subject: [PATCH] refactor to remove import from backend testing in order to use require --- services/auth/server/boot/specs/routes.spec.js | 6 +++--- .../client/common/methods/client/specs/addresses.spec.js | 4 ++-- .../methods/client/specs/addressesPropagateRe.spec.js | 6 +++--- services/client/common/methods/client/specs/card.spec.js | 4 ++-- services/client/common/methods/client/specs/create.spec.js | 6 +++--- .../client/common/methods/client/specs/employee.spec.js | 4 ++-- services/client/common/methods/client/specs/roles.spec.js | 4 ++-- .../client/common/methods/client/specs/salesperson.spec.js | 4 ++-- services/client/common/methods/greuge/specs/total.spec.js | 4 ++-- services/db/testing_fixtures.js | 5 ++--- services/utils/jasmineHelpers.js | 4 ++-- services_tests.js | 2 -- 12 files changed, 25 insertions(+), 28 deletions(-) diff --git a/services/auth/server/boot/specs/routes.spec.js b/services/auth/server/boot/specs/routes.spec.js index 2ea72a1e9..ca5ca06e0 100644 --- a/services/auth/server/boot/specs/routes.spec.js +++ b/services/auth/server/boot/specs/routes.spec.js @@ -1,6 +1,6 @@ -import app from '../../../server/server'; -import routes from '../routes'; -import restoreFixtures from '../../../../../services/db/testing_fixtures'; +let app = require('../../../server/server'); +let routes = require('../routes'); +let restoreFixtures = require('../../../../../services/db/testing_fixtures'); describe('Auth routes', () => { let fixturesToApply = {tables: ['`salix`.`user`'], inserts: [ diff --git a/services/client/common/methods/client/specs/addresses.spec.js b/services/client/common/methods/client/specs/addresses.spec.js index a56b9c981..809f80875 100644 --- a/services/client/common/methods/client/specs/addresses.spec.js +++ b/services/client/common/methods/client/specs/addresses.spec.js @@ -1,5 +1,5 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); describe('Client addresses', () => { it('should call the addressesList method and receive total results and items', done => { diff --git a/services/client/common/methods/client/specs/addressesPropagateRe.spec.js b/services/client/common/methods/client/specs/addressesPropagateRe.spec.js index 5e7a7bac5..d055cc86f 100644 --- a/services/client/common/methods/client/specs/addressesPropagateRe.spec.js +++ b/services/client/common/methods/client/specs/addressesPropagateRe.spec.js @@ -1,6 +1,6 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; -import restoreFixtures from '../../../../../../services/db/testing_fixtures'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); +let restoreFixtures = require('../../../../../../services/db/testing_fixtures'); describe('Client addressesPropagateRe', () => { let fixturesToApply = {tables: ['`account`.`user`', '`vn2008`.`Clientes`', '`vn2008`.`Consignatarios`'], inserts: [ diff --git a/services/client/common/methods/client/specs/card.spec.js b/services/client/common/methods/client/specs/card.spec.js index abe314fff..895097cac 100644 --- a/services/client/common/methods/client/specs/card.spec.js +++ b/services/client/common/methods/client/specs/card.spec.js @@ -1,5 +1,5 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); describe('Client card', () => { it('should call the card() method to receive a formated card of Bruce Wayne', done => { diff --git a/services/client/common/methods/client/specs/create.spec.js b/services/client/common/methods/client/specs/create.spec.js index e10fb62c6..9b6295483 100644 --- a/services/client/common/methods/client/specs/create.spec.js +++ b/services/client/common/methods/client/specs/create.spec.js @@ -1,6 +1,6 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; -import restoreFixtures from '../../../../../../services/db/testing_fixtures'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); +let restoreFixtures = require('../../../../../../services/db/testing_fixtures'); describe('Client Create', () => { let fixturesToApply = {tables: ['`account`.`user`', '`vn2008`.`Clientes`', '`vn2008`.`Consignatarios`'], inserts: [ diff --git a/services/client/common/methods/client/specs/employee.spec.js b/services/client/common/methods/client/specs/employee.spec.js index 2cbaa4020..04726aeb9 100644 --- a/services/client/common/methods/client/specs/employee.spec.js +++ b/services/client/common/methods/client/specs/employee.spec.js @@ -1,5 +1,5 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); describe('Client employeeList', () => { it('should call the employeeList()', done => { diff --git a/services/client/common/methods/client/specs/roles.spec.js b/services/client/common/methods/client/specs/roles.spec.js index 559d272b2..b6ef8240c 100644 --- a/services/client/common/methods/client/specs/roles.spec.js +++ b/services/client/common/methods/client/specs/roles.spec.js @@ -1,5 +1,5 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); describe('Client getRoleCustomer', () => { it('should call the getRoleCustomer() method with a customer id', done => { diff --git a/services/client/common/methods/client/specs/salesperson.spec.js b/services/client/common/methods/client/specs/salesperson.spec.js index fa5cc4ea7..c95b9bf52 100644 --- a/services/client/common/methods/client/specs/salesperson.spec.js +++ b/services/client/common/methods/client/specs/salesperson.spec.js @@ -1,5 +1,5 @@ -import app from '../../../../server/server'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; +let app = require('../../../../server/server'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); describe('Client activeSalesPerson', () => { it('should call the activeSalesPerson() method with limit of 1', done => { diff --git a/services/client/common/methods/greuge/specs/total.spec.js b/services/client/common/methods/greuge/specs/total.spec.js index 846ce752e..b088692fc 100644 --- a/services/client/common/methods/greuge/specs/total.spec.js +++ b/services/client/common/methods/greuge/specs/total.spec.js @@ -1,5 +1,5 @@ -import totalGreuge from '../total'; -import {catchErrors} from '../../../../../../services/utils/jasmineHelpers'; +let totalGreuge = require('../total'); +let catchErrors = require('../../../../../../services/utils/jasmineHelpers'); describe('Greuge totalGreuge()', () => { it('should call the sumAmount method', done => { diff --git a/services/db/testing_fixtures.js b/services/db/testing_fixtures.js index 21954fb19..9b7fa6b65 100644 --- a/services/db/testing_fixtures.js +++ b/services/db/testing_fixtures.js @@ -32,11 +32,10 @@ let truncate = (tables, callback) => { connection.connect(); -export default function restoreFixtures(fixturesToApply, callback) { +module.exports = function restoreFixtures(fixturesToApply, callback) { connection.query('SET FOREIGN_KEY_CHECKS = 0', () => { truncate(fixturesToApply.tables, () => { insertFixtures(fixturesToApply.inserts, callback); }); }); -} - +}; diff --git a/services/utils/jasmineHelpers.js b/services/utils/jasmineHelpers.js index 11a808d1d..ab45069c3 100644 --- a/services/utils/jasmineHelpers.js +++ b/services/utils/jasmineHelpers.js @@ -1,8 +1,8 @@ -export function catchErrors(done) { +module.exports = function catchErrors(done) { return error => { if (error instanceof Error) { return done.fail(error.stack); } return done.fail(JSON.stringify(error)); }; -} +}; diff --git a/services_tests.js b/services_tests.js index f3fccbde3..d91e31c84 100644 --- a/services_tests.js +++ b/services_tests.js @@ -1,5 +1,3 @@ -require('babel-core/register')({presets: ['es2015']}); - process.env.NODE_ENV = 'test'; process.on('warning', warning => {