Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Commit

Permalink
Add a test of querying strictly.
Browse files Browse the repository at this point in the history
  • Loading branch information
rictic committed Mar 6, 2017
1 parent 8070f57 commit 78173a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/html/html-import-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ const isLazyImportNode = p.AND(
p.hasAttr('href'),
p.NOT(p.hasSpaceSeparatedAttrValue('rel', 'import')),
notCssLink,
p.parentMatches(
p.AND(p.hasTagName('dom-module'), p.NOT(p.hasTagName('template')))));
p.NOT(p.parentMatches(p.hasTagName('template'))));

/**
* Scans for <link rel="import"> and <link rel="lazy-import">
Expand Down
38 changes: 22 additions & 16 deletions src/test/analyzer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,30 @@ suite('Analyzer', () => {
const root = await analyzer.analyze('static/dependencies/root.html');

// If we ask for documents we get every document in evaluation order.
const strictlyReachableDocuments = [
['static/dependencies/root.html', 'html', false],
['static/dependencies/inline-only.html', 'html', false],
['static/dependencies/inline-only.html', 'js', true],
['static/dependencies/inline-only.html', 'css', true],
['static/dependencies/leaf.html', 'html', false],
['static/dependencies/inline-and-imports.html', 'html', false],
['static/dependencies/inline-and-imports.html', 'js', true],
['static/dependencies/subfolder/in-folder.html', 'html', false],
['static/dependencies/subfolder/subfolder-sibling.html', 'html', false],
['static/dependencies/inline-and-imports.html', 'css', true],
];
assert.deepEqual(
Array
.from(root.getByKind(
'document', {imported: true, strictImports: true}))
.map((d) => [d.url, d.parsedDocument.type, d.isInline]),
strictlyReachableDocuments);
assert.deepEqual(
Array.from(root.getByKind('document', {imported: true}))
.map((d) => [d.url, d.parsedDocument.type, d.isInline]),
[
['static/dependencies/root.html', 'html', false],
['static/dependencies/inline-only.html', 'html', false],
['static/dependencies/inline-only.html', 'js', true],
['static/dependencies/inline-only.html', 'css', true],
['static/dependencies/leaf.html', 'html', false],
['static/dependencies/inline-and-imports.html', 'html', false],
['static/dependencies/inline-and-imports.html', 'js', true],
['static/dependencies/subfolder/in-folder.html', 'html', false],
[
'static/dependencies/subfolder/subfolder-sibling.html',
'html',
false
],
['static/dependencies/inline-and-imports.html', 'css', true],
]);
strictlyReachableDocuments.concat(
[['static/dependencies/lazy.html', 'html', false]]));


// If we ask for imports we get the import statements in evaluation order.
// Unlike documents, we can have duplicates here because imports exist
Expand All @@ -320,6 +325,7 @@ suite('Analyzer', () => {
'static/dependencies/subfolder/in-folder.html',
'static/dependencies/subfolder/subfolder-sibling.html',
'static/dependencies/subfolder/in-folder.html',
'static/dependencies/lazy.html',
]);

const inlineOnly = root.getOnlyAtId(
Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/test/static/dependencies/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
<link rel="import" href="leaf.html">
<link rel="import" href="inline-and-imports.html">
<link rel="import" href="subfolder/in-folder.html">
<link rel="lazy-import" href="lazy.html">

0 comments on commit 78173a4

Please sign in to comment.