1 | var test = require('tape')
|
2 | , {{PascalName}}Pane = require('./index.js')
|
3 | , sinon = require('sinon')
|
4 | , _ = require('lodash')
|
5 | , defaultOptions = {}
|
6 | , createView = function createView(options){
|
7 | return new {{PascalName}}Pane(_.defaults(options || {}, defaultOptions))
|
8 | }
|
9 | , stopListening
|
10 | , setup = function setup(){
|
11 | stopListening = sinon.spy({{PascalName}}Pane.prototype, 'stopListening')
|
12 | }
|
13 | , cleanup = function cleanup(){
|
14 | stopListening.restore()
|
15 | }
|
16 |
|
17 | test('Pane: {{PascalName}}: constructor', function constructorTest(t){
|
18 | var view = createView()
|
19 |
|
20 | t.equal(
|
21 | typeof view
|
22 | , 'object'
|
23 | , 'creates an object'
|
24 | )
|
25 |
|
26 | t.end()
|
27 | })
|
28 |
|
29 | test('Pane: {{PascalName}}#bindEvents', function bindEventsTest(t){
|
30 | var view = createView()
|
31 | , fn = view.bindEvents
|
32 |
|
33 | setup()
|
34 |
|
35 |
|
36 | fn.call(view)
|
37 | t.equal(
|
38 | stopListening.callCount
|
39 | , 1
|
40 | , 'calls stopListening so that events aren\'t bound multiple times'
|
41 | )
|
42 | t.ok(
|
43 | stopListening.calledWith(view.state)
|
44 | , 'calls stopListening with the state so that not all listeners are removed'
|
45 | )
|
46 |
|
47 | cleanup()
|
48 | t.end()
|
49 | })
|
50 |
|
51 | test('Pane: {{PascalName}}#beforeInit', function beforeInitTest(t){
|
52 | var view = createView()
|
53 | , fn = view.beforeInit
|
54 | , options = defaultOptions
|
55 |
|
56 | fn.call(view, options)
|
57 | t.ok(
|
58 | view.state instanceof view.State
|
59 | , 'creates a state model'
|
60 | )
|
61 |
|
62 | t.end()
|
63 | })
|
64 |
|
65 | test('Pane: {{PascalName}} properties', function propertiesTest(t){
|
66 | var view = createView()
|
67 |
|
68 | t.ok(
|
69 | view.navBarTitle
|
70 | , 'sets a title'
|
71 | )
|
72 |
|
73 | t.ok(
|
74 | view.navBarRightButton
|
75 | , 'sets a right button'
|
76 | )
|
77 |
|
78 | t.end()
|
79 | })
|