UNPKG

2.4 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright (c) 2017 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 chai_1 = require("chai");
17const path = require("path");
18const polymer_project_1 = require("../polymer-project");
19const testProjectRoot = path.resolve('test-fixtures/custom-elements-es5-adapter');
20suite('Babel Helpers Injecter', () => {
21 let defaultProject;
22 const unroot = ((p) => p.substring(testProjectRoot.length + 1));
23 setup(() => {
24 defaultProject = new polymer_project_1.PolymerProject({
25 root: 'test-fixtures/custom-elements-es5-adapter/',
26 entrypoint: 'index.html',
27 shell: 'shell.html',
28 sources: [
29 'source-dir/**',
30 ],
31 });
32 });
33 test('injects babel helpers inline into the entrypoint', (done) => {
34 const webcomponentsLoaderFilename = 'webcomponents-loader.js';
35 const files = new Map();
36 defaultProject.sources()
37 .pipe(defaultProject.addBabelHelpersInEntrypoint())
38 .on('data', (f) => files.set(unroot(f.path), f))
39 .on('data', () => { })
40 .on('end', () => {
41 const expectedFiles = [
42 'index.html',
43 'shell.html',
44 ];
45 chai_1.assert.deepEqual(Array.from(files.keys()).sort(), expectedFiles);
46 const index = files.get('index.html').contents.toString();
47 const shell = files.get('shell.html').contents.toString();
48 chai_1.assert.include(index, 'babelHelpers=');
49 chai_1.assert(index.indexOf('babelHelpers=') <
50 index.indexOf(webcomponentsLoaderFilename), 'babel helpers should come before all other executable code.');
51 chai_1.assert.notInclude(shell, 'babelHelpers=');
52 done();
53 });
54 });
55});
56//# sourceMappingURL=inject-babel-helpers_test.js.map
\No newline at end of file