forked from premieroctet/openchakra
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sosynpl[premieroctet#155]: added creator to question
- Loading branch information
1 parent
577f88d
commit 0605f9c
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const mongoose = require('mongoose') | ||
const moment = require('moment') | ||
const { MONGOOSE_OPTIONS, loadFromDb } = require('../../server/utils/database') | ||
const CustomerFreelance = require('../../server/models/CustomerFreelance') | ||
const Question = require('../../server/models/Question') | ||
const { CUSTOMER_DATA } = require('./data/base_data') | ||
require('../../server/plugins/sosynpl/functions') | ||
require('../../server/models/Sector') | ||
require('../../server/models/JobFile') | ||
require('../../server/models/Job') | ||
|
||
describe('Questions', () => { | ||
|
||
beforeAll(async () => { | ||
const DBNAME = `test${moment().unix()}` | ||
await mongoose.connect(`mongodb://localhost/${DBNAME}`, MONGOOSE_OPTIONS) | ||
}) | ||
|
||
afterAll(async () => { | ||
await mongoose.connection.dropDatabase() | ||
await mongoose.connection.close() | ||
}) | ||
|
||
it('must get question creator', async() => { | ||
await CustomerFreelance.create({...CUSTOMER_DATA}) | ||
const user = await CustomerFreelance.findOne({}) | ||
await Question.create({creator: user._id, title:'Test'}) | ||
const [question] = await loadFromDb({model:'question', user, fields:['creator.fullname','title']}) | ||
expect(question.creator.fullname).toEqual(user.fullname) | ||
}) | ||
}) |