diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-11-02 17:50:18 +0100 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-11-03 14:28:18 +0100 |
commit | 6805619766655e0e2e0d375503d65d5818c0c6a6 (patch) | |
tree | 625b6bba4ef44442f341db0a6552b5aeb7e354f3 /server/sonar-web/src/main/js/helpers/testUtils.ts | |
parent | a950deadd1f474fa50fe2de1c5aace5468f23c63 (diff) | |
download | sonarqube-6805619766655e0e2e0d375503d65d5818c0c6a6.tar.gz sonarqube-6805619766655e0e2e0d375503d65d5818c0c6a6.zip |
SONAR-9225 Make all search bars consistent
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/testUtils.ts')
-rw-r--r-- | server/sonar-web/src/main/js/helpers/testUtils.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/helpers/testUtils.ts b/server/sonar-web/src/main/js/helpers/testUtils.ts index 01b046039dc..8665b925032 100644 --- a/server/sonar-web/src/main/js/helpers/testUtils.ts +++ b/server/sonar-web/src/main/js/helpers/testUtils.ts @@ -56,11 +56,18 @@ export function keydown(keyCode: number): void { } export function elementKeydown(element: ShallowWrapper, keyCode: number): void { - element.simulate('keydown', { + const event = { currentTarget: { element }, keyCode, preventDefault() {} - }); + }; + + if (typeof element.type() === 'string') { + // `type()` is string for native dom elements + element.simulate('keydown', event); + } else { + element.prop<Function>('onKeyDown')(event); + } } export function doAsync(fn?: Function): Promise<void> { |