1 | {MockDocument} = require('../lib/karen')
|
2 |
|
3 | describe 'MockDocument', ->
|
4 | def 'document', -> new MockDocument
|
5 |
|
6 | describe '#cookie', ->
|
7 | it 'sets cookie string', ->
|
8 | @document.cookie = 'foo=bar; domain=.domain.com; path=/'
|
9 | @document.cookie = 'baz=qux; domain=.domain.com; path=/'
|
10 | @document.cookie.should.equal('foo=bar; baz=qux')
|
11 |
|
12 | it 'emits cookie event', (done) ->
|
13 | @document.on 'cookie', (name, value, options) ->
|
14 | name.should.equal('foo')
|
15 | value.should.equal('bar')
|
16 | options.domain.should.equal('.domain.com')
|
17 | options.path.should.equal('/')
|
18 | done()
|
19 | @document.cookie = 'foo=bar; domain=.domain.com; path=/'
|
20 |
|
21 | describe '#body', ->
|
22 | it 'returns a MockNode with type body', ->
|
23 | @document.body.type.should.equal('body')
|
24 |
|
25 | it 'returns same object every time', ->
|
26 | @document.body.should.equal(@document.body)
|
27 |
|
28 | describe '#head', ->
|
29 | it 'returns a MockNode with type head', ->
|
30 | @document.head.type.should.equal('head')
|
31 |
|
32 | it 'returns same object every time', ->
|
33 | @document.head.should.equal(@document.head)
|
34 |
|
35 | describe '#defaultView', ->
|
36 | it 'returns a MockWindow object', ->
|
37 | @document.defaultView.should.be.an('object')
|
38 |
|
39 | it 'returns same object every time', ->
|
40 | @document.defaultView.should.equal(@document.defaultView)
|
41 |
|
42 | describe '#parentWindow', ->
|
43 | it 'returns a MockWindow object', ->
|
44 | @document.parentWindow.should.be.an('object')
|
45 |
|
46 | it 'returns same object every time', ->
|
47 | @document.parentWindow.should.equal(@document.parentWindow)
|
48 |
|
49 | describe '#documentElement', ->
|
50 | it 'returns a MockNode with type documentElement', ->
|
51 | @document.documentElement.type.should.equal('documentElement')
|
52 |
|
53 | it 'returns same object every time', ->
|
54 | @document.documentElement.should.equal(@document.documentElement)
|
55 |
|
56 | describe '#domain', ->
|
57 | it 'returns localhost', ->
|
58 | @document.domain.should.equal('localhost')
|
59 |
|
60 | describe '#readyState', ->
|
61 | it 'is complete', ->
|
62 | @document.readyState.should.equal('complete')
|
63 |
|
64 | describe '#getElementById', ->
|
65 | it 'returns null', ->
|
66 | expect(@document.getElementById('id')).to.be.null
|