ProjectList = require '../../coffee/views/project-list'
ProjectItem = require '../../coffee/views/project-item'

describe 'Project list view', ->
  projectList = new ProjectList()

  it 'should be a div element', ->
    projectList.tagName.should.equal('div')

  it 'should have the right class', ->
    projectList.className.should.equal('project-list')

  it 'should be a Backbone view', ->
    projectList.should.be.an.instanceof(Backbone.View)

  it 'should store a list of items', ->
    projectList.items.should.be.an.instanceof(Array)

  it 'should have no items by default', ->
    projectList.items.should.have.length(0)

  it 'should support adding a single item to the list', ->
    projectList.add({name: 'foo'})
    projectList.items.should.have.length(1)
    projectList.items[0].name.should.equal('foo')

  it 'should support adding multiple items at once', ->
    projectList.add([{name: 'bar'}, {name: 'baz'}])
    projectList.items.should.have.length(3)

  it 'should add the right kind of objects', ->
    projectList.items[0].should.be.an.instanceof(ProjectItem)

  describe 'render', ->
    it 'should return a reference of the object', ->
      projectList.render().should.equal(projectList)
