refactor to remove import from backend testing in order to use require
This commit is contained in:
parent
fbc327302b
commit
215ae09b70
|
@ -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: [
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require('babel-core/register')({presets: ['es2015']});
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
process.on('warning', warning => {
|
||||
|
|
Loading…
Reference in New Issue