aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/helpers/testUtils.ts
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-11-09 14:44:07 +0100
committerSonarTech <sonartech@sonarsource.com>2018-11-16 20:21:06 +0100
commite86e8c1fe6f96ea84d2f38ee01b3610d21eebe94 (patch)
treec3cc3465112ccff2055867a4b143664ed9108f1f /server/sonar-web/src/main/js/helpers/testUtils.ts
parent4e72416a414f4651cf9e0347b161c9be74b9782a (diff)
downloadsonarqube-e86e8c1fe6f96ea84d2f38ee01b3610d21eebe94.tar.gz
sonarqube-e86e8c1fe6f96ea84d2f38ee01b3610d21eebe94.zip
SONAR-11321 Improve project page manual fields validate
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/testUtils.ts')
-rw-r--r--server/sonar-web/src/main/js/helpers/testUtils.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/js/helpers/testUtils.ts b/server/sonar-web/src/main/js/helpers/testUtils.ts
index 17ae73d203f..ed1f5f42a4b 100644
--- a/server/sonar-web/src/main/js/helpers/testUtils.ts
+++ b/server/sonar-web/src/main/js/helpers/testUtils.ts
@@ -52,11 +52,19 @@ export function submit(element: ShallowWrapper | ReactWrapper): void {
}
export function change(element: ShallowWrapper | ReactWrapper, value: string, event = {}): void {
- element.simulate('change', {
- target: { value },
- currentTarget: { value },
- ...event
- });
+ // `type()` returns a component constructor for a composite element and string for DOM nodes
+ if (typeof element.type() === 'function') {
+ element.prop<Function>('onChange')(value);
+ // TODO find out if `root` is a public api
+ // https://github.com/airbnb/enzyme/blob/master/packages/enzyme/src/ReactWrapper.js#L109
+ (element as any).root().update();
+ } else {
+ element.simulate('change', {
+ target: { value },
+ currentTarget: { value },
+ ...event
+ });
+ }
}
export function keydown(keyCode: number): void {