Skip to content

Commit e886bbe

Browse files
Fix tests
1 parent 4e7b956 commit e886bbe

File tree

2 files changed

+52
-32
lines changed

2 files changed

+52
-32
lines changed

tests/src/ace.spec.tsx

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ describe("Ace Component", () => {
433433
});
434434
// //inspired from https://github.com/goodtimeaj/debounce-function/blob/master/test/unit/debounce-function.js
435435
describe("Debounce function", () => {
436-
it("function arg should be called when after timeout", done => {
436+
it("function arg should be called when after timeout", async () => {
437437
let instance;
438438
const wrapper = mount(
439439
<AceEditor
@@ -448,13 +448,15 @@ describe("Ace Component", () => {
448448
}, 100);
449449
func();
450450
expect(flag).toBeFalsy();
451-
setTimeout(function () {
452-
expect(flag).toBeTruthy;
453-
done();
454-
}, 150);
451+
await new Promise(resolve => {
452+
setTimeout(function () {
453+
expect(flag).toBeTruthy();
454+
resolve();
455+
}, 150);
456+
});
455457
});
456458

457-
it("timer should be reset on successive call", done => {
459+
it("timer should be reset on successive call", async () => {
458460
let instance;
459461
const wrapper = mount(
460462
<AceEditor
@@ -470,20 +472,31 @@ describe("Ace Component", () => {
470472
}, 100);
471473
func();
472474
expect(flag).toBeFalsy();
473-
setTimeout(function () {
474-
expect(flag).toBeFalsy();
475-
func();
476-
}, 50);
477-
setTimeout(function () {
478-
expect(flag).toBeFalsy();
479-
}, 120);
480-
setTimeout(function () {
481-
expect(flag).toBeTruthy();
482-
done();
483-
}, 160);
475+
476+
await new Promise(resolve => {
477+
setTimeout(function () {
478+
expect(flag).toBeFalsy();
479+
func();
480+
resolve();
481+
}, 50);
482+
});
483+
484+
await new Promise(resolve => {
485+
setTimeout(function () {
486+
expect(flag).toBeFalsy();
487+
resolve();
488+
}, 70);
489+
});
490+
491+
await new Promise(resolve => {
492+
setTimeout(function () {
493+
expect(flag).toBeTruthy();
494+
resolve();
495+
}, 40);
496+
});
484497
});
485498

486-
it("function should be called only once per period", done => {
499+
it("function should be called only once per period", async () => {
487500
let instance;
488501
const wrapper = mount(
489502
<AceEditor
@@ -505,21 +518,32 @@ describe("Ace Component", () => {
505518
func();
506519
expect(flag1).toBeFalsy();
507520
expect(flag2).toBeFalsy();
508-
setTimeout(function () {
509-
expect(flag1).toBeFalsy();
510-
expect(flag2).toBeFalsy();
511-
func();
521+
522+
await new Promise(resolve => {
523+
setTimeout(function () {
524+
expect(flag1).toBeFalsy();
525+
expect(flag2).toBeFalsy();
526+
func();
527+
resolve();
528+
}, 50);
529+
});
530+
531+
await new Promise(resolve => {
512532
setTimeout(function () {
513533
expect(flag1).toBeTruthy();
514534
expect(flag2).toBeFalsy();
515535
func();
516-
setTimeout(function () {
517-
expect(flag1).toBeTruthy();
518-
expect(flag2).toBeFalsy();
519-
done();
520-
}, 90);
536+
resolve();
521537
}, 110);
522-
}, 50);
538+
});
539+
540+
await new Promise(resolve => {
541+
setTimeout(function () {
542+
expect(flag1).toBeTruthy();
543+
expect(flag2).toBeFalsy();
544+
resolve();
545+
}, 90);
546+
});
523547
});
524548
it("should keep initial value after undo event", () => {
525549
let instance;

tests/src/split.spec.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ describe("Split Component", () => {
107107
instance = node!;
108108
}}
109109
splits={2}
110-
ref={node => {
111-
instance = node!;
112-
}}
113-
splits={2}
114110
/>
115111
);
116112

0 commit comments

Comments
 (0)