setup for back end unit test up and runing, fixtures pending

This commit is contained in:
Carlos Jimenez 2018-01-16 21:39:40 +01:00
parent c757fd798f
commit bfcbf23de8
7 changed files with 82 additions and 8 deletions

View File

@ -1,7 +1,14 @@
import app from '../../../../server/server';
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()', () => {
beforeEach(() => {
restoreFixtures();
});
let data = {
name: 'MaxEisenhardt',
userName: 'Magneto',
@ -10,6 +17,15 @@ describe('Client Create()', () => {
socialName: 'The X-Men'
};
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.Account.findOne({where: {name: data.userName}})

View File

@ -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`)
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`)
VALUES

View File

@ -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');
}

View File

@ -24,4 +24,3 @@
"acquireTimeout": 20000
}
}

View File

@ -1,5 +1,7 @@
require('babel-core/register')({presets: ['es2015']});
process.env.NODE_ENV = 'test';
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);