-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathasync-nesting.test.ts
More file actions
35 lines (28 loc) · 901 Bytes
/
async-nesting.test.ts
File metadata and controls
35 lines (28 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { describe, expect } from '@jest/globals';
import { spaceTrim } from '../spaceTrim';
// tslint:disable:no-trailing-whitespace
describe('how nesting works', () => {
it('will asynchronously nest simple values ', () => {
return expect(
spaceTrim(
async (block) => `
${block('Hello asynchronous')}
`,
),
).resolves.toBe('Hello asynchronous');
});
it('will asynchronously nest simple values ', () => {
const nested = new Promise<string>((resolve) => {
setTimeout(() => {
resolve('100ms timeout');
}, 100);
});
return expect(
spaceTrim(
async (block) => `
Hello ${block(await nested)}
`,
),
).resolves.toBe('Hello 100ms timeout');
});
});