blob: c6da4cdf27919dffa1c99eb57e7d13221632c8c2 (
plain)
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
36
|
/**
* @license
* Copyright 2018 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import {describe, it} from 'node:test';
import expect from 'expect';
import {interpolateFunction} from './Function.js';
describe('Function', function () {
describe('interpolateFunction', function () {
it('should work', async () => {
const test = interpolateFunction(
() => {
const test = PLACEHOLDER('test') as () => number;
return test();
},
{test: `() => 5`}
);
expect(test()).toBe(5);
});
it('should work inlined', async () => {
const test = interpolateFunction(
() => {
// Note the parenthesis will be removed by the typescript compiler.
return (PLACEHOLDER('test') as () => number)();
},
{test: `() => 5`}
);
expect(test()).toBe(5);
});
});
});
|