Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump handlebars from 4.1.2 to 4.7.3 in /reference-implementation #1

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
571 changes: 44 additions & 527 deletions README.md

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions reference-implementation/__tests__/helpers/common-test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const assert = require('assert');
const { URL } = require('url');
const { parseFromString } = require('../../lib/parser.js');
const { resolve } = require('../../lib/resolver.js');
const { traceDepcache } = require('../../lib/depcache.js');

function assertNoExtraProperties(object, expectedProperties, description) {
for (const actualProperty in object) {
Expand Down Expand Up @@ -59,7 +60,7 @@ function runTests(j) {
assertNoExtraProperties(
j,
[
'expectedResults', 'expectedParsedImportMap',
'expectedResults', 'expectedParsedImportMap', 'expectedDepcache',
'baseURL', 'name', 'parsedImportMap',
'importMap', 'importMapBaseURL',
'link', 'details'
Expand All @@ -85,8 +86,9 @@ function runTests(j) {
}
assert(
'expectedResults' in j ||
'expectedParsedImportMap' in j,
'expectedResults or expectedParsedImportMap should exist'
'expectedParsedImportMap' in j ||
'expectedDepcache' in j,
'expectedResults, expectedParsedImportMap or expectedDepcache should exist'
);

// Resolution tests.
Expand Down Expand Up @@ -123,6 +125,25 @@ function runTests(j) {
}
});
}

// Depcache tests
if ('expectedDepcache' in j) {
it(j.name, () => {
assertOwnProperty(j, 'baseURL');
describe(
'Import map registration should be successful for resolution tests',
() => {
expect(j.parsedImportMap).not.toBeInstanceOf(Error);
}
);

for (const specifier in j.expectedDepcache) {
const resolved = resolve(specifier, j.parsedImportMap, new URL(j.baseURL));
const traced = traceDepcache(resolved, j.parsedImportMap);
expect(traced).toEqual(j.expectedDepcache[specifier]);
}
});
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion reference-implementation/__tests__/helpers/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ expect.extend({
}

received = received.href;
expected = (new URL(expected)).href;
expected = new URL(expected).href;

const pass = received === expected;

Expand Down
42 changes: 42 additions & 0 deletions reference-implementation/__tests__/json/depcache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"importMapBaseURL": "https://example.com/app/index.html",
"tests": {
"Depcache resolution": {
"importMap": {
"imports": {
"a": "/a-1.mjs",
"b": "/scope/b-1.mjs"
},
"scopes": {
"/a-1.mjs": {
"a": "/a-2.mjs"
},
"/scope/": {
"a": "/scope/a-3.mjs",
"b": "./b-2.mjs"
}
},
"depcache": {
"/a-1.mjs": ["a"],
"/a-2.mjs": ["b"],
"/scope/b-1.mjs": ["./b-2.mjs"],
"/scope/b-2.mjs": ["a"]
}
},
"tests": {
"should trace full depcache": {
"baseURL": "https://example.com/scope2/foo.mjs",
"expectedDepcache": {
"a": [
"https://example.com/a-1.mjs",
"https://example.com/a-2.mjs",
"https://example.com/scope/b-1.mjs",
"https://example.com/scope/b-2.mjs",
"https://example.com/scope/a-3.mjs"
]
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"importMapBaseURL": "https://base.example/path1/path2/path3",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"about": "about:good",
"blob": "blob:good",
Expand Down Expand Up @@ -50,6 +51,7 @@
},
"importMapBaseURL": "https://base.example/path1/path2/path3",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"unparseable2": null,
"unparseable3": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"importMapBaseURL": "https://base.example/path1/path2/path3",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"foo1": null,
"foo2": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"tests": {
"should accept strings prefixed with ./, ../, or /": {
"importMap": {
"depcache": {},
"imports": {
"dotSlash": "./foo",
"dotDotSlash": "../foo",
Expand All @@ -11,6 +12,7 @@
},
"importMapBaseURL": "https://base.example/path1/path2/path3",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"dotSlash": "https://base.example/path1/path2/foo",
"dotDotSlash": "https://base.example/path1/foo",
Expand All @@ -21,6 +23,7 @@
},
"should not accept strings prefixed with ./, ../, or / for data: base URLs": {
"importMap": {
"depcache": {},
"imports": {
"dotSlash": "./foo",
"dotDotSlash": "../foo",
Expand All @@ -29,6 +32,7 @@
},
"importMapBaseURL": "data:text/html,test",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"dotSlash": null,
"dotDotSlash": null,
Expand All @@ -39,6 +43,7 @@
},
"should accept the literal strings ./, ../, or / with no suffix": {
"importMap": {
"depcache": {},
"imports": {
"dotSlash": "./",
"dotDotSlash": "../",
Expand All @@ -47,6 +52,7 @@
},
"importMapBaseURL": "https://base.example/path1/path2/path3",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"dotSlash": "https://base.example/path1/path2/",
"dotDotSlash": "https://base.example/path1/",
Expand All @@ -57,6 +63,7 @@
},
"should ignore percent-encoded variants of ./, ../, or /": {
"importMap": {
"depcache": {},
"imports": {
"dotSlash1": "%2E/",
"dotDotSlash1": "%2E%2E/",
Expand All @@ -69,6 +76,7 @@
},
"importMapBaseURL": "https://base.example/path1/path2/path3",
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"dotSlash1": null,
"dotDotSlash1": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"should normalize empty import maps to have imports and scopes keys": {
"importMap": {},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {}
}
Expand All @@ -14,6 +15,7 @@
"scopes": {}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {}
}
Expand All @@ -23,6 +25,7 @@
"imports": {}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {
"null": null,
"boolean": null,
Expand All @@ -36,6 +37,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"scops": {}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {}
}
Expand Down
10 changes: 10 additions & 0 deletions reference-implementation/__tests__/json/parsing-scope-keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/foo": {}
Expand All @@ -23,6 +24,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/foo": {},
Expand All @@ -41,6 +43,7 @@
},
"importMapBaseURL": "data:text/html,test",
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {}
}
Expand All @@ -54,6 +57,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/": {},
Expand All @@ -69,6 +73,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/foo/bar?baz#qux": {}
Expand All @@ -82,6 +87,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/path3": {}
Expand All @@ -99,6 +105,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/foo/": {},
Expand All @@ -123,6 +130,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/foo//": {
Expand All @@ -149,6 +157,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"about:good": {},
Expand Down Expand Up @@ -178,6 +187,7 @@
}
},
"expectedParsedImportMap": {
"depcache": {},
"imports": {},
"scopes": {
"https://base.example/path1/path2/example.org": {},
Expand Down
Loading