codecombat/test/server/models/LevelDraft.spec.coffee

32 lines
679 B
CoffeeScript
Raw Normal View History

2014-01-03 13:32:13 -05:00
require '../common'
describe 'LevelDraft', ->
level = new Level(
name: "King's Peak Redux"
description: 'Climb a mountain.'
permissions: simplePermissions
original: new ObjectId()
)
it 'clears things first', (done) ->
clearModels [Level, LevelDraft], (err) ->
expect(err).toBeNull()
done()
it 'saves', (done) ->
level.save (err) ->
throw err if err
draft = new LevelDraft(
user: new ObjectId()
level: level
)
draft.save (err) ->
throw err if err
LevelDraft.findOne {_id:draft._id}, (err, fetched) ->
2014-01-15 14:36:59 -05:00
expect(fetched.level.original).toBeDefined()
2014-01-03 13:32:13 -05:00
done()