UNPKG

1.63 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5 * This code may only be used under the BSD style license found at
6 * http://polymer.github.io/LICENSE.txt
7 * The complete set of authors may be found at
8 * http://polymer.github.io/AUTHORS.txt
9 * The complete set of contributors may be found at
10 * http://polymer.github.io/CONTRIBUTORS.txt
11 * Code distributed by Google as part of the polymer project is also
12 * subject to an additional IP rights grant found at
13 * http://polymer.github.io/PATENTS.txt
14 */
15Object.defineProperty(exports, "__esModule", { value: true });
16const babelCore = require("@babel/core");
17const stripIndent = require("strip-indent");
18const chai_1 = require("chai");
19const path = require("path");
20const babel_plugin_bare_specifiers_1 = require("../babel-plugin-bare-specifiers");
21suite('babel-plugin-bare-specifiers', () => {
22 const rootDir = path.join(__dirname, '..', '..', 'test-fixtures', 'npm-modules');
23 const filePath = path.join(rootDir, 'foo.js');
24 const resolveBareSpecifiersTransform = babel_plugin_bare_specifiers_1.resolveBareSpecifiers(filePath, false);
25 test('transforms import()', () => {
26 const input = stripIndent(`
27 const dep1 = import('dep1');
28 `);
29 const expected = stripIndent(`
30 const dep1 = import("./node_modules/dep1/index.js");
31 `);
32 const result = babelCore.transform(input, { plugins: [resolveBareSpecifiersTransform] })
33 .code;
34 chai_1.assert.equal(result.trim(), expected.trim());
35 });
36});
37//# sourceMappingURL=babel-plugin-bare-specifiers_test.js.map
\No newline at end of file