test('compiles ES2017 to ES2015', async () => { const result = jsTransform( 'async function test() { await 0; }', {compile: 'es2015'}); assert.include(result, 'asyncToGenerator'); assert.notInclude(result, 'async function test'); assert.notInclude(result, 'regeneratorRuntime'); });
test('compiles ES2017 to ES2015', async () => { const sourceStream = createFakeFileStream([ { path: 'foo.js', contents: `async function test() { await 0; }`, }, ]); const op = pipeStreams( [sourceStream, getOptimizeStreams({js: {compile: 'es2015'}})]); const result = await getOnlyFile(op); assert.include(result, 'asyncToGenerator'); assert.notInclude(result, 'async function test'); assert.notInclude(result, 'regeneratorRuntime'); });
.on('end', () => { const expectedJoinedFiles = [ 'index.html', 'shell.html', path.join('source-dir', 'my-app.html'), ]; assert.deepEqual( Array.from(joinedFiles.keys()).sort(), expectedJoinedFiles); const shell = joinedFiles.get('shell.html').contents.toString(); assert.notInclude(shell, '<html', 'html element was added'); assert.notInclude(shell, '<head', 'head element was added'); assert.notInclude(shell, '<body', 'body element was added'); done(); });
test('creates a filesystem path using the platform separators', () => { const otherSeparator = pathSeparator === '/' ? '\\' : '/'; const path = pathFromUrl(RootPath, '/some/url/pathname' as PackageRelativeUrl); assert.include(path, pathSeparator); assert.notInclude(path, otherSeparator); });
test('add prefetch links for transitive deps of bundled', async () => { const project = new PolymerProject({ root: 'test-fixtures/bundle-project/', entrypoint: 'index.html', fragments: ['simple-import.html'], }); const files = await emittedFiles( mergeStream(project.sources(), project.dependencies()) .pipe(project.bundler({inlineScripts: false})) .pipe(project.addPrefetchLinks()), project.config.root); const expectedFiles = ['index.html', 'simple-import.html', 'simple-script.js']; assert.deepEqual(expectedFiles, [...files.keys()].sort()); const html = files.get('index.html')!.contents!.toString(); // `simple-import.html` is a direct dependency, so we should not add // prefetch link to it. assert.notInclude( html, '<link rel="prefetch" href="/simple-import.html">'); // `simple-import.html` has inlined `simple-import-2.html` which has an // external script import `simple-script.js`. A prefetch link is added // for `simple-script.js` because it is a transitive dependency of the // `index.html` assert.include(html, '<link rel="prefetch" href="/simple-script.js">'); });
test('adds prefetch links for transitive deps of unbundled', async () => { const project = new PolymerProject({ root: 'test-fixtures/bundle-project/', entrypoint: 'index.html', }); const files = await emittedFiles( mergeStream(project.sources(), project.dependencies()) .pipe(project.addPrefetchLinks()), project.config.root); const html = files.get('index.html').contents.toString(); // No prefetch links needed for direct dependency. assert.notInclude( html, '<link rel="prefetch" href="/simple-import.html">'); // Prefetch added for the transitive dependencies of `index.html`, // which are all direct dependencies of `simple-import.html`. assert.include(html, '<link rel="prefetch" href="/simple-script.js">'); assert.include(html, '<link rel="prefetch" href="/simple-style.css">'); assert.include( html, '<link rel="prefetch" href="/simple-import-2.html">'); });
it("doesn't warn if non-existent file is excluded by --exclude", async () => { const result = await execRunnerWithOutput({ exclude: ["**/*.js"], files: ["foo/bar.js"], }); assert.strictEqual(result.status, Status.Ok, "process should exit without error"); assert.notInclude(result.stderr, "does not exist"); });
it("doesn't warn if glob pattern doesn't match any file", async () => { const result = await execRunnerWithOutput({ files: ["*.js"], project: "test/files/tsconfig-test/tsconfig.json", }); assert.strictEqual(result.status, Status.Ok, "process should exit without error"); assert.notInclude(result.stderr, "does not exist"); });
it("doesn't warn for non-existent file-to-lint if excluded by --exclude", async () => { const result = await execRunnerWithOutput({ exclude: ["**/*"], files: ["test/files/tsconfig-test/non-existent.test.ts"], project: "test/files/tsconfig-test/tsconfig.json", }); assert.strictEqual(result.status, Status.Ok, "process should exit without error"); assert.notInclude(result.stderr, "does not exist"); });
.on('end', () => { const expectedFiles = [ 'index.html', 'shell.html', ]; assert.deepEqual(Array.from(files.keys()).sort(), expectedFiles); const index = files.get('index.html').contents.toString(); assert.include(index, 'index stuff'); assert.include(index, '<base href="/newBase/">'); assert.notInclude(index, 'oldBase'); const shell = files.get('shell.html').contents.toString(); assert.include(shell, 'shell stuff'); assert.include(shell, 'shell-stuff/'); assert.notInclude(shell, 'newBase'); done(); });