Sha256: b0889b51d776e7f94a6373353bf559d35f386c98c2fd0a2002e77111cc945b5a

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

describe "Lanes.Models.Collection", ->


    it "it triggers promise on loading", (done) ->
        Model = Lanes.Test.defineModel
            props: { id: 'integer', title: 'string' }

        LT.syncSucceedWith([
            { id: 1, title: 'first value'  }
            { id: 2, title: 'second value' }
        ])
        collection = Model.where(name: 'foo')
        expect(collection.requestInProgress).toBeDefined()
        collection.whenLoaded ->
            expect( collection.isLoaded() ).toBe(true)
            done()

    it "triggers length when changed", ->
        Model = Lanes.Test.defineModel
            props: { id: 'integer', title: 'string' }

        collection = new Model.Collection
        spy = jasmine.createSpy('onLengthChange')
        collection.on("change:length", spy)
        model = collection.add({ id: 1, title: 'first' })
        expect(spy).toHaveBeenCalled()
        spy.calls.reset()
        collection.remove(model)
        expect(spy).toHaveBeenCalled()
        spy.calls.reset()
        collection.reset([{ id:11, title: 'last'}])
        expect(spy).toHaveBeenCalled()

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lanes-0.8.3 spec/lanes/models/CollectionSpec.coffee
lanes-0.8.2 spec/lanes/models/CollectionSpec.coffee
lanes-0.8.1 spec/lanes/models/CollectionSpec.coffee
lanes-0.8.0 spec/lanes/models/CollectionSpec.coffee
lanes-0.7.0 spec/lanes/models/CollectionSpec.coffee
lanes-0.6.1 spec/lanes/models/CollectionSpec.coffee
lanes-0.6.0 spec/lanes/models/CollectionSpec.coffee
lanes-0.5.6 spec/lanes/models/CollectionSpec.coffee
lanes-0.5.5 spec/lanes/models/CollectionSpec.coffee
lanes-0.5.0 spec/lanes/models/CollectionSpec.coffee
lanes-0.4.0 spec/lanes/models/CollectionSpec.coffee