project_title_spec.js.coffee 983 Bytes
Newer Older
Phil Hughes's avatar
Phil Hughes committed
1
#= require bootstrap
Phil Hughes's avatar
Phil Hughes committed
2
#= require select2
Connor Shea's avatar
Connor Shea committed
3
#= require lib/utils/type_utility
Phil Hughes's avatar
Phil Hughes committed
4
#= require gl_dropdown
Phil Hughes's avatar
Phil Hughes committed
5 6 7 8
#= require api
#= require project_select
#= require project

9
window.gon or= {}
Phil Hughes's avatar
Phil Hughes committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
window.gon.api_version = 'v3'

describe 'Project Title', ->
  fixture.preload('project_title.html')
  fixture.preload('projects.json')

  beforeEach ->
    fixture.load('project_title.html')
    @project = new Project()

  describe 'project list', ->
    beforeEach =>
      @projects_data = fixture.load('projects.json')[0]

      spyOn(jQuery, 'ajax').and.callFake (req) =>
25
        expect(req.url).toBe('/api/v3/projects.json?simple=true')
Phil Hughes's avatar
Phil Hughes committed
26 27 28 29 30 31
        d = $.Deferred()
        d.resolve @projects_data
        d.promise()

    it 'to show on toggle click', =>
      $('.js-projects-dropdown-toggle').click()
Phil Hughes's avatar
Phil Hughes committed
32
      expect($('.header-content').hasClass('open')).toBe(true)
Phil Hughes's avatar
Phil Hughes committed
33 34

    it 'hide dropdown', ->
Phil Hughes's avatar
Phil Hughes committed
35
      $(".dropdown-menu-close-icon").click()
Phil Hughes's avatar
Phil Hughes committed
36

Phil Hughes's avatar
Phil Hughes committed
37
      expect($('.header-content').hasClass('open')).toBe(false)