graphic_spec.js.coffee
1.16 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#= require jquery
#= require spec_helper
#= require modules
#= require module/graphic
#= require sinon
describe "Module.Graphic", ->
describe "constructor", ->
before ->
@container = 'container404829'
@metric_name = 'Pain'
@module_id = '54405'
@drawer = sinon.stub()
sinon.stub(window, "$")
$.withArgs("tr#"+@container).returns(@drawer)
context 'when the drawer is hidden', ->
before ->
@drawer.is = sinon.stub().withArgs(':hidden').returns(true)
it "should show the drawer and start to load a graphic", ->
@drawer.slideDown = sinon.spy()
Module.Graphic.prototype.load = sinon.spy()
@graphic = new Module.Graphic(@container, @metric_name, @module_id)
assert.isTrue(@drawer.slideDown.calledOnce)
assert.isTrue(@graphic.load.calledOnce)
context 'when the drawer is visible', ->
before ->
@drawer.is = sinon.stub().withArgs(':hidden').returns(false)
it 'should hide the drawer', ->
@drawer.slideUp = sinon.spy()
@graphic = new Module.Graphic(@container, @metric_name, @module_id)
assert.isTrue(@drawer.slideUp.calledOnce)