Created
September 27, 2012 00:27
-
-
Save bobzoller/3791467 to your computer and use it in GitHub Desktop.
mongoose set nested bug?
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
| mongoose = require 'mongoose' | |
| schema = new mongoose.Schema | |
| nested: | |
| thing: String | |
| Bob = mongoose.model('Bob', schema) | |
| describe 'Bob', -> | |
| bob = null | |
| beforeEach -> | |
| bob = new Bob(nested: {thing: 'widget'}) | |
| expect(bob.nested.thing).toEqual 'widget' | |
| it 'set null', -> | |
| bob.set(nested: null) | |
| expect(bob.get('nested.thing')).toBeUndefined() | |
| it 'set undefined', -> | |
| bob.set(nested: undefined) | |
| expect(bob.get('nested.thing')).toBeUndefined() | |
| it 'set empty object', -> | |
| bob.set(nested: {}) | |
| expect(bob.get('nested.thing')).toBeUndefined() | |
| it 'virtual property null', -> | |
| bob.nested = null | |
| expect(bob.get('nested.thing')).toBeUndefined() | |
| it 'virtual property undefined', -> | |
| bob.nested = undefined | |
| expect(bob.get('nested.thing')).toBeUndefined() | |
| it 'virtual property empty object', -> | |
| bob.nested = {} | |
| expect(bob.get('nested.thing')).toBeUndefined() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run with
jasmine-node --coffee bob.spec.coffee