Sha256: e30bc4db90453a03e49ddc971e1603dffd993829474c368b5a3c0a19984480db

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

describe "Hippo.Models.Collection", ->


    it "it triggers promise on loading", (done) ->
        Model = Hippo.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 = Hippo.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

9 entries across 9 versions & 1 rubygems

Version Path
hippo-fw-0.9.9 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.8 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.7 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.6 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.5 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.4 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.3 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.2 spec/hippo/models/CollectionSpec.coffee
hippo-fw-0.9.1 spec/hippo/models/CollectionSpec.coffee