@dxos/async 0.6.13 → 0.6.14-main.2b6a0f3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,11 +2,9 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
- import waitForExpect from 'wait-for-expect';
5
+ import { describe, expect, test } from 'vitest';
7
6
 
8
7
  import { Context } from '@dxos/context';
9
- import { describe, test } from '@dxos/test';
10
8
 
11
9
  import { DeferredTask, scheduleTask } from './task-scheduling';
12
10
  import { sleep } from './timeout';
@@ -25,9 +23,7 @@ describe('task-scheduling', () => {
25
23
  throw new Error('test');
26
24
  });
27
25
 
28
- await waitForExpect(() => {
29
- expect(error.message).to.eq('test');
30
- });
26
+ await expect.poll(() => error.message).toBe('test');
31
27
  });
32
28
 
33
29
  test('cancelation', async () => {
@@ -61,6 +61,7 @@ export class DeferredTask {
61
61
  if (this._ctx.disposed) {
62
62
  throw new ContextDisposedError();
63
63
  }
64
+
64
65
  this.schedule();
65
66
  await this._nextTask.wait();
66
67
  }
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { test } from '@dxos/test';
5
+ import { test } from 'vitest';
6
6
 
7
7
  import { TestStream } from './test-stream';
8
8
 
@@ -2,10 +2,9 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
5
+ import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { expectToThrow } from '@dxos/debug';
8
- import { describe, test } from '@dxos/test';
9
8
 
10
9
  import { waitForCondition } from './testing';
11
10
 
@@ -2,10 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
-
7
- import { expectToThrow } from '@dxos/debug';
8
- import { describe, test } from '@dxos/test';
5
+ import { describe, expect, test } from 'vitest';
9
6
 
10
7
  import { asyncTimeout, sleep } from './timeout';
11
8
 
@@ -18,7 +15,7 @@ describe('timeout', () => {
18
15
 
19
16
  test('fails', async () => {
20
17
  const promise = sleep(200).then(() => 'test');
21
- await expectToThrow(() => asyncTimeout(promise, 100, new Error('timeout')));
18
+ await expect(() => asyncTimeout(promise, 100, new Error('timeout'))).rejects.toThrowError();
22
19
  });
23
20
 
24
21
  test('sleep', async () => {
@@ -2,16 +2,11 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import chai, { expect } from 'chai';
6
- import chaiAsPromised from 'chai-as-promised';
7
-
8
- import { describe, test } from '@dxos/test';
5
+ import { describe, expect, test } from 'vitest';
9
6
 
10
7
  import { sleep } from './timeout';
11
8
  import { Trigger, TriggerState, trigger } from './trigger';
12
9
 
13
- chai.use(chaiAsPromised);
14
-
15
10
  describe('trigger', () => {
16
11
  test('trigger', async () => {
17
12
  const [value, setValue] = trigger<any>();
@@ -52,7 +47,7 @@ describe('trigger', () => {
52
47
  const error = new Error('Test error');
53
48
  const promise = trigger.wait();
54
49
  trigger.throw(error);
55
- await expect(promise).to.be.rejectedWith(error);
50
+ await expect(promise).rejects.toThrowError(error);
56
51
  expect(trigger.state).to.equal(TriggerState.REJECTED);
57
52
  trigger.reset();
58
53
  expect(trigger.state).to.equal(TriggerState.WAITING);
package/src/until.test.ts CHANGED
@@ -2,10 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
6
-
7
- import { expectToThrow } from '@dxos/debug';
8
- import { describe, test } from '@dxos/test';
5
+ import { describe, expect, test } from 'vitest';
9
6
 
10
7
  import { sleep } from './timeout';
11
8
  import { until } from './until';
@@ -22,29 +19,29 @@ describe('until', () => {
22
19
  });
23
20
 
24
21
  test('error', async () => {
25
- await expectToThrow(async () => {
22
+ await expect(async () => {
26
23
  await until(async (resolve, reject) => {
27
24
  await sleep(100);
28
25
  reject(new Error());
29
26
  });
30
- });
27
+ }).rejects.toThrowError();
31
28
  });
32
29
 
33
30
  test('catch', async () => {
34
- await expectToThrow(async () => {
31
+ await expect(async () => {
35
32
  await until(async () => {
36
33
  await sleep(100);
37
34
  throw new Error();
38
35
  });
39
- });
36
+ }).rejects.toThrowError();
40
37
  });
41
38
 
42
39
  test('timeout', async () => {
43
- await expectToThrow(async () => {
40
+ await expect(async () => {
44
41
  await until(async (resolve) => {
45
42
  await sleep(500);
46
43
  resolve();
47
44
  }, 100); // Timeout before complete.
48
- });
45
+ }).rejects.toThrowError();
49
46
  });
50
47
  });
@@ -2,10 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { expect } from 'chai';
5
+ import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { Context } from '@dxos/context';
8
- import { describe, test } from '@dxos/test';
9
8
 
10
9
  import { sleep } from './timeout';
11
10
  import { UpdateScheduler } from './update-scheduler';