UNPKG

fusion-cli

Version:
56 lines (50 loc) 1.33 kB
/** Copyright (c) 2018 Uber Technologies, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ /* eslint-env node */ const fs = require('fs'); const t = require('assert'); const {transformFileSync} = require('@babel/core'); const plugin = require('../'); test('import workerURL', () => { const output = transformFileSync( __dirname + '/fixtures/input-import-destructuring', { plugins: [plugin], } ); const expected = fs .readFileSync( __dirname + '/fixtures/expected-import-destructuring', 'utf-8' ) .trim(); t.equal(output.code, expected, 'replaced correctly'); }); test('import workerURL as', () => { const output = transformFileSync( __dirname + '/fixtures/input-import-destructuring-as', { plugins: [plugin], } ); const expected = fs .readFileSync( __dirname + '/fixtures/expected-import-destructuring-as', 'utf-8' ) .trim(); t.equal(output.code, expected, 'replaced correctly'); }); test('invalid arguments', () => { function output() { return transformFileSync(__dirname + '/fixtures/input-wrong-arg', { plugins: [plugin], }); } t.throws(output, /workerURL argument must be a string literal/); });