Skip to content

Commit ef3e7d8

Browse files
author
Jess
committed
Conditional spec to handle phantomJS not implementing KeyboardEvent.code
1 parent fd1a01b commit ef3e7d8

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Diff for: test/specs/wrapper/trigger.spec.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,24 @@ describeWithShallowAndMount('trigger', mountingMethod => {
3737
expect(keydownHandler.calledOnce).to.equal(true)
3838
})
3939

40-
it('causes keydown handler to fire with the appropriate keyCode when wrapper.trigger("keydown", { keyCode: 65 }) is fired on a Component', () => {
40+
describe('causes keydown handler to fire with the appropriate keyCode when wrapper.trigger("keydown", { keyCode: 65 }) is fired on a Component', () => {
4141
const keydownHandler = sandbox.stub()
4242
const wrapper = mountingMethod(ComponentWithEvents, {
4343
propsData: { keydownHandler }
4444
})
45+
4546
wrapper.find('.keydown').trigger('keydown', { keyCode: 65 })
4647

4748
const keyboardEvent = keydownHandler.getCall(0).args[0]
4849

4950
// Unfortunately, JSDom will give different types than PhantomJS for keyCodes (string vs number), so we have to use parseInt to normalize the types.
50-
expect(parseInt(keyboardEvent.keyCode, 10)).to.equal(65)
51-
expect(parseInt(keyboardEvent.code, 10)).to.equal(65)
51+
it('contains the keyCode', () => {
52+
expect(parseInt(keyboardEvent.keyCode, 10)).to.equal(65)
53+
})
54+
55+
itDoNotRunIf(isRunningPhantomJS, 'contains the code', () => {
56+
expect(parseInt(keyboardEvent.code, 10)).to.equal(65)
57+
})
5258
})
5359

5460
it('causes keydown handler to fire when wrapper.trigger("keydown.enter") is fired on a Component', () => {

Diff for: yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -4498,10 +4498,10 @@ flatten@^1.0.2:
44984498
version "1.0.2"
44994499
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
45004500

4501-
flow-bin@^0.111.0:
4502-
version "0.111.3"
4503-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.111.3.tgz#8653a413400ebc966097a47c81fb4e6b722a5921"
4504-
integrity sha512-Gn27aRTjSFicukZ/pq3raRERmSk9UWszhIK9eNtj6843L54YtK+jk2OkQWV70+VKi9LmWyfItCkhwoIVy7L2lA==
4501+
flow-bin@^0.66.0:
4502+
version "0.66.0"
4503+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.66.0.tgz#a96dde7015dc3343fd552a7b4963c02be705ca26"
4504+
integrity sha1-qW3ecBXcM0P9VSp7SWPAK+cFyiY=
45054505

45064506
flow-remove-types-no-whitespace@^1.0.3:
45074507
version "1.0.5"

0 commit comments

Comments
 (0)