Created
June 17, 2020 12:55
-
-
Save kianaditya/6e6b7110200618a99e8be56ffb9ba93f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const factoryGirl = require('factory-girl') | |
const adapter = new factoryGirl.SequelizeAdapter() | |
const factory = factoryGirl.factory | |
factory.setAdapter(adapter) | |
factory.cleanUp() | |
const db = require('../../src/models') | |
factory.define('Post', db.Post, async () => { | |
const attrs = { | |
id: factory.seq('Post.id'), | |
title: factory.chance('sentence', { words: 5 }), | |
content: factory.chance('sentence', { words: 15 }), | |
} | |
return attrs | |
}) | |
factory.define('User', db.User, async () => { | |
const attrs = { | |
id: factory.seq('User.id'), | |
firstName: factory.chance('first'), | |
lastName: factory.chance('last'), | |
} | |
return attrs | |
}) | |
module.exports = factory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment