Sha256: 5c317ed8545c9fb61386bb77f165c2fb9781af706b8251b7452f0ca1068fd973

Contents?: true

Size: 989 Bytes

Versions: 4

Compression:

Stored size: 989 Bytes

Contents

describe "Lanes.Models.Collection", ->


    it "it triggers promise on loading", (done)->
        Model = Lanes.Test.DummyModel
        syncSucceedWith([
            { id: 1, title: 'first value'  }
            { id: 2, title: 'second value' }
        ])
        collection = Model.where( name: 'foo' )
        collection.whenLoaded ->
            expect( collection.isLoaded() ).toEqual( true )
            done()

    it "triggers length when changed", ->
        collection = new Lanes.Test.DummyModel.Collection
        spy = jasmine.createSpy('onLengthChange')
        collection.on("change:length", spy)
        model = collection.add({ id: 1, title: 'first' })
        expect(model).toEqual(jasmine.any(Lanes.Test.DummyModel))
        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

4 entries across 4 versions & 1 rubygems

Version Path
lanes-0.1.8 spec/lanes/models/CollectionSpec.coffee
lanes-0.1.7 spec/lanes/models/CollectionSpec.coffee
lanes-0.1.6 spec/lanes/models/CollectionSpec.coffee
lanes-0.1.5 spec/lanes/models/CollectionSpec.coffee