setup for back end unit test up and runing, fixtures pending
This commit is contained in:
parent
c757fd798f
commit
bfcbf23de8
|
@ -1,7 +1,14 @@
|
||||||
|
import app from '../../../../server/server';
|
||||||
import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
|
import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
|
||||||
let app = require('../../../../server/server');
|
import {restoreFixtures} from '../../../../../../services/db/testing_fixtures';
|
||||||
|
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
|
|
||||||
describe('Client Create()', () => {
|
describe('Client Create()', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
restoreFixtures();
|
||||||
|
});
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
name: 'MaxEisenhardt',
|
name: 'MaxEisenhardt',
|
||||||
userName: 'Magneto',
|
userName: 'Magneto',
|
||||||
|
@ -10,7 +17,16 @@ describe('Client Create()', () => {
|
||||||
socialName: 'The X-Men'
|
socialName: 'The X-Men'
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should createa new account', done => {
|
it('should find jessica', done => {
|
||||||
|
app.models.Account.findOne({where: {name: 'CharlesXavier'}})
|
||||||
|
.then(account => {
|
||||||
|
expect(account.name).toEqual('CharlesXavier');
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(catchErrors(done));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new account', done => {
|
||||||
app.models.Client.createUserProfile(data, () => {
|
app.models.Client.createUserProfile(data, () => {
|
||||||
app.models.Account.findOne({where: {name: data.userName}})
|
app.models.Account.findOne({where: {name: data.userName}})
|
||||||
.then(account => {
|
.then(account => {
|
||||||
|
|
|
@ -459,7 +459,7 @@ INSERT INTO `vn2008`.`empresa_grupo`(`empresa_grupo_id`, `grupo`)
|
||||||
|
|
||||||
INSERT INTO `vn2008`.`empresa`(`id`, `abbreviation`, `registro`, `gerente_id`, `alta`, `baja`, `logo`, `oficial`, `cyc`, `rgb`, `mail`, `cuno`, `ODBC_DATE`, `Id_Cliente`, `digito_factura`, `Id_Proveedores_account`, `morosidad`, `empresa_grupo`)
|
INSERT INTO `vn2008`.`empresa`(`id`, `abbreviation`, `registro`, `gerente_id`, `alta`, `baja`, `logo`, `oficial`, `cyc`, `rgb`, `mail`, `cuno`, `ODBC_DATE`, `Id_Cliente`, `digito_factura`, `Id_Proveedores_account`, `morosidad`, `empresa_grupo`)
|
||||||
VALUES
|
VALUES
|
||||||
('442', 'WAY', 'Wayne Industries, Inc. operates as a warehouse for steel products. Wayne Industries, Inc. was founded in 1989 and is based in Wayne, Michigan.', '2', '1989-11-19', NULL, NULL, '1', '1', '00FF00', 'BruceWayne@verdnatura.es', NULL, '1989-08-11 12:31:22', '10', '1', NULL, '1', '1');
|
(442, 'WAY', 'Wayne Industries, Inc. operates as a warehouse for steel products. Wayne Industries, Inc. was founded in 1989 and is based in Wayne, Michigan.', '2', '1989-11-19', NULL, NULL, '1', '1', '00FF00', 'BruceWayne@verdnatura.es', NULL, '1989-08-11 12:31:22', '10', '1', NULL, '1', '1');
|
||||||
|
|
||||||
INSERT INTO `salix`.`Ticket`(`id`, `agencyFk`, `employeeFk`, `date`, `hour`, `clientFk`, `addressFk`)
|
INSERT INTO `salix`.`Ticket`(`id`, `agencyFk`, `employeeFk`, `date`, `hour`, `clientFk`, `addressFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
// let mysql = require('mysql');
|
||||||
|
|
||||||
|
// let connection = mysql.createConnection({
|
||||||
|
// multipleStatements: false,
|
||||||
|
// host: 'localhost',
|
||||||
|
// user: 'root',
|
||||||
|
// password: '',
|
||||||
|
// database: 'salix'
|
||||||
|
// });
|
||||||
|
// let connected;
|
||||||
|
// let firstQuery;
|
||||||
|
// let secondQuery;
|
||||||
|
// let thirdQuery;
|
||||||
|
// let start = Date.now();
|
||||||
|
// let end = false;
|
||||||
|
// let callback = (error, results, fields) => {
|
||||||
|
// thirdQuery = Date.now() - start - connected - firstQuery - secondQuery;
|
||||||
|
// console.log('connected', connected);
|
||||||
|
// console.log('firstQuery', firstQuery);
|
||||||
|
// console.log('secondQuery', secondQuery);
|
||||||
|
// console.log('thirdQuery', thirdQuery);
|
||||||
|
|
||||||
|
// if (error) {
|
||||||
|
// connection.end();
|
||||||
|
// throw error;
|
||||||
|
// }
|
||||||
|
// if (end)
|
||||||
|
// connection.end();
|
||||||
|
// };
|
||||||
|
|
||||||
|
// let truncate = (error, results, fields) => {
|
||||||
|
// if (error) {
|
||||||
|
// connection.end();
|
||||||
|
// connection.query('SET FOREIGN_KEY_CHECKS = 1', callback);
|
||||||
|
// throw error;
|
||||||
|
// }
|
||||||
|
// let truncatesSQL = results.reduce((accumulator, currentValue, i) => {
|
||||||
|
// let sql = 'TRUNCATE TABLE `' + currentValue.table_schema + '`.`' + currentValue.table_name + '`; ';
|
||||||
|
// return `${accumulator}${sql}`;
|
||||||
|
// }, '');
|
||||||
|
|
||||||
|
// end = true;
|
||||||
|
// connection.query(truncatesSQL.slice(0, -2), callback);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// connection.connect();
|
||||||
|
// connected = Date.now() - start;
|
||||||
|
// connection.query('SET FOREIGN_KEY_CHECKS = 0', callback);
|
||||||
|
// firstQuery = Date.now() - start - connected;
|
||||||
|
// connection.query(`SELECT table_schema, table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema IN ('account', 'bi','bs', 'cache', 'edi', 'hedera', 'pbx', 'salix', 'util', 'vn', 'vn2008', 'vncontrol') AND table_rows < 1;`, truncate);
|
||||||
|
// secondQuery = Date.now() - start - connected - firstQuery;
|
||||||
|
|
||||||
|
export function restoreFixtures() {
|
||||||
|
// connection.connect();
|
||||||
|
// connection.query('CALL truncateDatabase'); calls the MySQL procedure
|
||||||
|
console.log('fixtures restored');
|
||||||
|
}
|
|
@ -23,5 +23,4 @@
|
||||||
"connectTimeout": 20000,
|
"connectTimeout": 20000,
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ module.exports = {
|
||||||
console.log('Mail sent ' + info.messageId + ' [' + info.response + ']');
|
console.log('Mail sent ' + info.messageId + ' [' + info.response + ']');
|
||||||
|
|
||||||
cb();
|
cb();
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -85,7 +85,7 @@ module.exports = {
|
||||||
params.attachments.forEach(function(attachment) {
|
params.attachments.forEach(function(attachment) {
|
||||||
result.attachments.push(attachment);
|
result.attachments.push(attachment);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.send(result.recipient, result.subject, result.body, result.attachments, params, error => {
|
this.send(result.recipient, result.subject, result.body, result.attachments, params, error => {
|
||||||
if (error)
|
if (error)
|
||||||
return cb(error);
|
return cb(error);
|
||||||
|
|
|
@ -7,7 +7,7 @@ function getFile(fileName) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let envFile = 'datasources.development.json';
|
let envFile = 'datasources.development.json';
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'test')
|
if (process.env.NODE_ENV === 'test')
|
||||||
envFile = 'datasources.test.json';
|
envFile = 'datasources.test.json';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
require('babel-core/register')({presets: ['es2015']});
|
require('babel-core/register')({presets: ['es2015']});
|
||||||
|
|
||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
process.on('warning', warning => {
|
process.on('warning', warning => {
|
||||||
console.log(warning.name);
|
console.log(warning.name);
|
||||||
console.log(warning.message);
|
console.log(warning.message);
|
||||||
|
|
Loading…
Reference in New Issue