Skip to content

Commit 00dc159

Browse files
committed
Fix incorrect tests
1 parent c4d2dbc commit 00dc159

File tree

4 files changed

+14
-50
lines changed

4 files changed

+14
-50
lines changed

packages/ember-cli-fastboot/lib/broccoli/html-writer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ module.exports = class BasePageWriter extends Filter {
2525
processString(content) {
2626
let dom = new JSDOM(content);
2727
let scriptTags = dom.window.document.querySelectorAll('script');
28-
2928
this._ignoreUnexpectedScripts(scriptTags);
3029

3130
let fastbootScripts = this._findFastbootScriptToInsert(scriptTags);
3231
let appJsTag = findAppJsTag(scriptTags, this._appJsPath, this._rootURL);
32+
if (!appJsTag) {
33+
throw new Error('ember-cli-fastboot cannot find own app script tag');
34+
}
3335
insertFastbootScriptsBeforeAppJsTags(fastbootScripts, appJsTag);
3436

3537
return dom.serialize();
@@ -79,6 +81,10 @@ function getRootURL(appName, config) {
7981
}
8082

8183
function urlWithin(candidate, root) {
84+
// this is a null or relative path
85+
if (!candidate || !candidate.startsWith('/')) {
86+
return candidate;
87+
}
8288
let candidateURL = new URL(candidate, 'http://_the_current_origin_');
8389
let rootURL = new URL(root, 'http://_the_current_origin_');
8490
if (candidateURL.href.startsWith(rootURL.href)) {

test-packages/basic-app/test/package-json-test.js

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe("generating package.json", function () {
3636
it("contains a schema version", function () {
3737
let pkg = fs.readJSONSync("dist/package.json");
3838

39-
expect(pkg.fastboot.schemaVersion).to.deep.equal(3);
39+
expect(pkg.fastboot.schemaVersion).to.deep.equal(5);
4040
});
4141

4242
it("contains a whitelist of allowed module names", function () {
@@ -54,25 +54,6 @@ describe("generating package.json", function () {
5454
]);
5555
});
5656

57-
it("contains a manifest of FastBoot assets", function () {
58-
let pkg = fs.readJSONSync("dist/package.json");
59-
60-
expect(pkg.fastboot.manifest).to.deep.equal({
61-
appFiles: [
62-
"assets/basic-app.js",
63-
"assets/basic-app-fastboot.js",
64-
"example-addon/bar.js",
65-
],
66-
htmlFile: "index.html",
67-
vendorFiles: [
68-
"example-addon/foo.js",
69-
"assets/vendor.js",
70-
"assets/auto-import-fastboot.js",
71-
"ember-fetch/fetch-fastboot.js",
72-
],
73-
});
74-
});
75-
7657
it("contains a list of whitelisted hosts from environment.js", function () {
7758
let pkg = fs.readJSONSync("dist/package.json");
7859

@@ -86,7 +67,7 @@ describe("generating package.json", function () {
8667
it("contains app name", function () {
8768
let pkg = fs.readJSONSync("dist/package.json");
8869

89-
expect(pkg.fastboot.appName).to.equal("basic-app");
70+
expect(pkg.name).to.equal("basic-app");
9071
});
9172

9273
it("contains the application config", function () {
@@ -132,28 +113,5 @@ describe("generating package.json", function () {
132113

133114
expect(pkg.fastboot.config["foo"]).to.equal("bar");
134115
});
135-
136-
});
137-
138-
describe("with production FastBoot builds", function () {
139-
before(async function () {
140-
await execa("yarn", ["build", "--environment=production"]);
141-
});
142-
143-
it("contains a manifest of FastBoot assets", function () {
144-
let pkg = fs.readJSONSync("dist/package.json");
145-
146-
let manifest = pkg.fastboot.manifest;
147-
148-
manifest.appFiles.forEach((file) => {
149-
expect(`dist/${file}`).to.be.a.file();
150-
});
151-
152-
expect(`dist/${manifest.htmlFile}`).to.be.a.file();
153-
154-
manifest.vendorFiles.forEach((file) => {
155-
expect(`dist/${file}`).to.be.a.file();
156-
});
157-
});
158116
});
159117
});

test-packages/custom-fastboot-app/public/custom-index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
<!-- EMBER_CLI_FASTBOOT_HEAD -->
1111

1212
<link rel="stylesheet" href="assets/vendor.css">
13-
<link rel="stylesheet" href="assets/custom-html-file.css">
13+
<link rel="stylesheet" href="assets/custom-fastboot-app.css">
1414
</head>
1515
<body>
1616
<!-- EMBER_CLI_FASTBOOT_BODY -->
1717

1818
<script src="assets/vendor.js"></script>
19-
<script src="assets/custom-html-file.js"></script>
19+
<script src="assets/custom-fastboot-app.js"></script>
2020
</body>
2121
</html>

test-packages/custom-fastboot-app/test/package-json-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ describe("generating package.json", function () {
5252
describe('with custom htmlFile', function() {
5353
it('uses custom htmlFile in the manifest', function() {
5454
let pkg = fs.readJSONSync("dist/package.json");
55-
let manifest = pkg.fastboot.manifest;
55+
let { htmlEntrypoint} = pkg.fastboot;
5656

57-
expect(manifest.htmlFile).to.equal('custom-index.html');
58-
expect(`dist/${manifest.htmlFile}`).to.be.a.file();
57+
expect(htmlEntrypoint).to.equal('custom-index.html');
58+
expect(`dist/${htmlEntrypoint}`).to.be.a.file();
5959
});
6060
});
6161
});

0 commit comments

Comments
 (0)