Skip to content

Commit

Permalink
[open-formulieren/open-forms#3611] Actually let jest run the expectat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
Viicos committed Nov 21, 2023
1 parent d245e80 commit d18c7ac
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions src/jstests/formio/components/time.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash';
import {Formio} from 'react-formio';

import OpenFormsModule from 'formio/module';
import {sleep} from 'utils';

import {timeForm} from './fixtures/time';

Expand All @@ -28,14 +29,13 @@ describe('Time Component', () => {
const component = form.getComponent('time');
const changed = component.setValue(value);
expect(changed).toBeTruthy();
setTimeout(() => {
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
}, 300);
await sleep(300);
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
});

it.each(['00:00:00', '23:59:59', '11:11:11'])(
Expand Down Expand Up @@ -71,14 +71,13 @@ describe('Time Component', () => {
const component = form.getComponent('time');
const changed = component.setValue(value);
expect(changed).toBeTruthy();
setTimeout(() => {
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
}, 300);
await sleep(300);
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
});

it.each([
Expand All @@ -96,14 +95,13 @@ describe('Time Component', () => {
const component = form.getComponent('time');
const changed = component.setValue(value);
expect(changed).toBeTruthy();
setTimeout(() => {
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
}, 300);
await sleep(300);
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
});

it.each([
Expand All @@ -126,14 +124,14 @@ describe('Time Component', () => {
const component = form.getComponent('time');
const changed = component.setValue(value);
expect(changed).toBeTruthy();
setTimeout(() => {
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
}, 300);

await sleep(300);
if (valid) {
expect(!!component.error).toBeFalsy();
} else {
expect(!!component.error).toBeTruthy();
expect(component.error.message).toEqual('invalid_time');
}
}
);

Expand Down

0 comments on commit d18c7ac

Please sign in to comment.