1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | const chai_1 = require("chai");
|
17 | const path = require("path");
|
18 | const polymer_project_1 = require("../polymer-project");
|
19 | const testProjectRoot = path.resolve('test-fixtures/custom-elements-es5-adapter');
|
20 | suite('Custom Elements ES5 Adapter', () => {
|
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 the custom elements es5 adapter in index', (done) => {
|
34 | const webcomponentsLoaderFilename = 'webcomponents-loader.js';
|
35 | const injectedAdapterFilename = 'custom-elements-es5-adapter.js';
|
36 | const files = new Map();
|
37 | defaultProject.sources()
|
38 | .pipe(defaultProject.addCustomElementsEs5Adapter())
|
39 | .pipe(defaultProject.addBabelHelpersInEntrypoint())
|
40 | .on('data', (f) => files.set(unroot(f.path), f))
|
41 | .on('data', () => { })
|
42 | .on('end', () => {
|
43 | const expectedFiles = [
|
44 | 'index.html',
|
45 | 'shell.html',
|
46 | ];
|
47 | chai_1.assert.deepEqual(Array.from(files.keys()).sort(), expectedFiles);
|
48 | const index = files.get('index.html').contents.toString();
|
49 | const shell = files.get('shell.html').contents.toString();
|
50 | chai_1.assert.include(index, injectedAdapterFilename);
|
51 | chai_1.assert.include(index, webcomponentsLoaderFilename);
|
52 | chai_1.assert.include(index, 'babelHelpers=');
|
53 | chai_1.assert(index.indexOf(injectedAdapterFilename) <
|
54 | index.indexOf(webcomponentsLoaderFilename), 'the es5 adapter should come before webcomponents-loader');
|
55 | chai_1.assert(index.indexOf('babelHelpers=') <
|
56 | index.indexOf(injectedAdapterFilename), 'babel helpers should come before all executable code');
|
57 | chai_1.assert.notInclude(shell, injectedAdapterFilename);
|
58 | done();
|
59 | });
|
60 | });
|
61 | });
|
62 |
|
\ | No newline at end of file |