Added Jest for testing both front and backend

This commit is contained in:
Jori Lallo
2016-09-09 01:35:39 -07:00
parent f4d1e62c13
commit 458735f341
21 changed files with 370 additions and 18 deletions

29
server/test/support.js Normal file
View File

@@ -0,0 +1,29 @@
import { User } from '../models';
import { sequelize } from '../sequelize';
export function flushdb() {
const sql = sequelize.getQueryInterface();
const tables = Object.keys(sequelize.models).map((model) =>
sql.quoteTable(sequelize.models[model].getTableName()));
const query = `TRUNCATE ${tables.join(', ')} CASCADE`;
return sequelize.query(query);
}
const seed = async () => {
await User.create({
id: '86fde1d4-0050-428f-9f0b-0bf77f8bdf61',
email: 'user1@example.com',
username: 'user1',
name: 'User 1',
slackId: '123',
slackData: {
image_192: 'http://example.com/avatar.png',
},
});
};
export {
seed,
sequelize,
};