Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 20, 2024
1 parent 7fc638f commit fb14cff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/DataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ class DataSource {
}

let entries = [];
for(let entry of dataEntries) {
for(let rawEntry of dataEntries) {
if(typeof this.cleanEntry === "function") {
let cleaned = await this.cleanEntry(entry, data);
let cleaned = await this.cleanEntry(rawEntry, data);
entries.push(cleaned);
} else {
entries.push(entry)
entries.push(rawEntry);
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/Fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ class Fetcher {
verbose: true,
showErrors: true,
}).then(result => {
let contextPathname = DirectoryManager.getDirectory(contextEntry.filePath);
let contextPathname;
if(contextEntry.filePath) {
contextPathname = DirectoryManager.getDirectory(contextEntry.filePath);
} else {
contextPathname = Fetcher.getContextPathname(contextEntry.url);
}
let filename = Fetcher.getFilenameFromSrc(url, result.headers?.["content-type"]);
let assetUrlLocation = path.join(this.#assetsFolder, filename);
let fullOutputLocation = path.join(contextPathname, assetUrlLocation);
Expand Down
9 changes: 6 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("YouTube user", async (t) => {
assert.equal(entries.length, 15);

let [post] = entries;
assert.deepEqual(Object.keys(post).sort(), ["authors", "content", "contentType", "date", "dateUpdated", "title", "type", "url", "uuid"]);
assert.deepEqual(Object.keys(post).sort(), ["authors", "content", "contentType", "date", "dateUpdated", "filePath", "title", "type", "url", "uuid"]);
assert.equal(post.content.length, 812);
assert.equal(post.authors[0].name, "Eleventy");
});
Expand Down Expand Up @@ -54,7 +54,7 @@ test("WordPress import", async (t) => {
assert.equal(entries.length, 1);

let [post] = entries;
assert.deepEqual(Object.keys(post).sort(), ["authors", "content", "contentType", "date", "dateUpdated", "metadata", "status", "title", "type", "url", "uuid"]);
assert.deepEqual(Object.keys(post).sort(), ["authors", "content", "contentType", "date", "dateUpdated", "filePath", "metadata", "status", "title", "type", "url", "uuid"]);
assert.equal(post.content.length, 6134);
assert.equal(post.authors[0].name, "Matt Johnson");
});
Expand All @@ -70,7 +70,10 @@ test("addSource using DataSource", async (t) => {
static TYPE_FRIENDLY = "Arbitrary";

getData() {
return [{ lol: "hi" }];
return [{
lol: "hi",
url: "https://example.com/test/"
}];
}
}

Expand Down

0 comments on commit fb14cff

Please sign in to comment.