summaryrefslogtreecommitdiff
path: root/spec/javascripts/models/auto_collection_spec.js.coffee
blob: 182417741b594aa6a75b3293afb25ced2705e223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
describe "AutoCollection", ->
  subject = null
  beforeEach ->
    subject = csx.AutoCollection

  describe ".install", ->
    it "installs a categories collection", ->
      subject.install('Category', [id: 1, name: 'cakes'])

      collection = csx.Collections.Category
      expect(collection).not.toBe(undefined)
      expect(collection.length).toEqual(1)
      expect(collection.first().get('name')).toEqual('cakes')

    it "binds the proper model", ->
      subject.install('Category', [])
      expect(csx.Collections.Category.model).toEqual(csx.Models.Category)

    it "binds the proper url", ->
      subject.install('Cake', [])
      expect(csx.Collections.Cake.url).toEqual('/api/v1/cakes')


#class csx.Collections.CakesCollection extends Backbone.Collection
  #model: csx.Models.Cake
  #url: '/api/v1/cakes'