Skip to content

Commit

Permalink
all unit tests pass in IE9
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Oct 13, 2013
1 parent b2c4882 commit 160ddb5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/.jshintrc
Expand Up @@ -19,7 +19,7 @@
"mock": true,
"Seed": true,
"$": true,
"mockChangeEvent": true,
"mockHTMLEvent": true,
"mockMouseEvent": true,
"mockKeyEvent": true
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/runner.html
Expand Up @@ -30,9 +30,9 @@
return el
}

function mockChangeEvent () {
function mockHTMLEvent (type) {
var e = document.createEvent('HTMLEvents')
e.initEvent('change', true, true)
e.initEvent(type, true, true)
return e
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/api.js
Expand Up @@ -295,7 +295,7 @@ describe('UNIT: API', function () {
input.value = 'hohoho'
input.dispatchEvent(mockKeyEvent('keyup'))
assert.strictEqual(t.test, 'hi')
input.dispatchEvent(mockChangeEvent())
input.dispatchEvent(mockHTMLEvent('change'))
assert.strictEqual(t.test, 'hohoho')
})

Expand Down
16 changes: 12 additions & 4 deletions test/unit/specs/directives.js
Expand Up @@ -318,7 +318,7 @@ describe('UNIT: Directives', function () {
assert.equal(val, 1)
}}
dir.el.options.selectedIndex = 1
dir.el.dispatchEvent(mockChangeEvent())
dir.el.dispatchEvent(mockHTMLEvent('change'))
assert.ok(triggered)
})

Expand All @@ -328,7 +328,7 @@ describe('UNIT: Directives', function () {
removed = false
}}
dir.unbind()
dir.el.dispatchEvent(mockChangeEvent())
dir.el.dispatchEvent(mockHTMLEvent('change'))
assert.ok(removed)
})

Expand Down Expand Up @@ -445,6 +445,10 @@ describe('UNIT: Directives', function () {
var dir = mockDirective('on')
dir.arg = 'click'

before(function () {
document.body.appendChild(dir.el)
})

it('should set the handler to be triggered by arg through update()', function () {
var triggered = false
dir.update(function () {
Expand Down Expand Up @@ -505,18 +509,22 @@ describe('UNIT: Directives', function () {

dir.arg = 'focus'
dir.update(handler)
dir.el.focus()
dir.el.dispatchEvent(mockHTMLEvent('focus'))
assert.strictEqual(triggerCount, 1)

dir.arg = 'blur'
dir.update(handler)
dir.el.blur()
dir.el.dispatchEvent(mockHTMLEvent('blur'))
assert.strictEqual(triggerCount, 2)

document.body.removeChild(dir.el)

})

after(function () {
document.body.removeChild(dir.el)
})

})

describe('pre', function () {
Expand Down

0 comments on commit 160ddb5

Please sign in to comment.