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/differential-serving');
|
20 | suite('updateBaseTag', () => {
|
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/differential-serving/',
|
26 | entrypoint: 'index.html',
|
27 | shell: 'shell.html',
|
28 | });
|
29 | });
|
30 | test('updates the entrypoint base tag', (done) => {
|
31 | const files = new Map();
|
32 | defaultProject.sources()
|
33 | .pipe(defaultProject.updateBaseTag('/newBase/'))
|
34 | .on('data', (f) => files.set(unroot(f.path), f))
|
35 | .on('data', () => { })
|
36 | .on('end', () => {
|
37 | const expectedFiles = [
|
38 | 'index.html',
|
39 | 'shell.html',
|
40 | ];
|
41 | chai_1.assert.deepEqual(Array.from(files.keys()).sort(), expectedFiles);
|
42 | const index = files.get('index.html').contents.toString();
|
43 | chai_1.assert.include(index, 'index stuff');
|
44 | chai_1.assert.include(index, '<base href="/newBase/">');
|
45 | chai_1.assert.notInclude(index, 'oldBase');
|
46 | const shell = files.get('shell.html').contents.toString();
|
47 | chai_1.assert.include(shell, 'shell stuff');
|
48 | chai_1.assert.include(shell, 'shell-stuff/');
|
49 | chai_1.assert.notInclude(shell, 'newBase');
|
50 | done();
|
51 | });
|
52 | });
|
53 | test('does nothing when base tag doesn\'t need updating', (done) => {
|
54 | const files = new Map();
|
55 | defaultProject.sources()
|
56 | .pipe(defaultProject.updateBaseTag('/oldBase/'))
|
57 | .on('data', (f) => files.set(unroot(f.path), f))
|
58 | .on('data', () => { })
|
59 | .on('end', () => {
|
60 | const expectedFiles = [
|
61 | 'index.html',
|
62 | 'shell.html',
|
63 | ];
|
64 | chai_1.assert.deepEqual(Array.from(files.keys()).sort(), expectedFiles);
|
65 | const index = files.get('index.html').contents.toString();
|
66 | chai_1.assert.include(index, '<base href="/oldBase/">');
|
67 | done();
|
68 | });
|
69 | });
|
70 | });
|
71 |
|
\ | No newline at end of file |