tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Function.test.ts (889B)


      1 /**
      2 * @license
      3 * Copyright 2018 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 import {describe, it} from 'node:test';
      8 
      9 import expect from 'expect';
     10 
     11 import {interpolateFunction} from './Function.js';
     12 
     13 describe('Function', function () {
     14  describe('interpolateFunction', function () {
     15    it('should work', async () => {
     16      const test = interpolateFunction(
     17        () => {
     18          const test = PLACEHOLDER('test') as () => number;
     19          return test();
     20        },
     21        {test: `() => 5`},
     22      );
     23      expect(test()).toBe(5);
     24    });
     25    it('should work inlined', async () => {
     26      const test = interpolateFunction(
     27        () => {
     28          // Note the parenthesis will be removed by the typescript compiler.
     29          return (PLACEHOLDER('test') as () => number)();
     30        },
     31        {test: `() => 5`},
     32      );
     33      expect(test()).toBe(5);
     34    });
     35  });
     36 });