diff --git a/test/expected-goodreads-content.js b/test/__mocks__/expected-goodreads-content.js similarity index 100% rename from test/expected-goodreads-content.js rename to test/__mocks__/expected-goodreads-content.js diff --git a/test/__mocks__/https.js b/test/__mocks__/https.js index 744b403..c272bf6 100644 --- a/test/__mocks__/https.js +++ b/test/__mocks__/https.js @@ -1,6 +1,6 @@ const fs = require('fs') -const fakedata = fs.readFileSync('./test/expected-goodreads-content.js') +const fakedata = fs.readFileSync('./test/__mocks__/expected-goodreads-content.js') function getmock(url, callback) { callback({ diff --git a/test/__snapshots__/howlong-tobeat.test.js.snap b/test/__snapshots__/howlong-tobeat.test.js.snap new file mode 100644 index 0000000..d860c0a --- /dev/null +++ b/test/__snapshots__/howlong-tobeat.test.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`howlong adds howlong to beat id and hours to frontmatter 1`] = ` +"--- +title: \\"wizardry 8 review\\" +howlongtobeat_id: 11228 +howlongtobeat_hrs: 93 +game_name: \\"Wizardry 8\\" +--- + +blabla nice one 9/10 GG! +" +`; diff --git a/test/__snapshots__/masto-feed-parser.test.js.snap b/test/__snapshots__/masto-feed-parser.test.js.snap new file mode 100644 index 0000000..7e75640 --- /dev/null +++ b/test/__snapshots__/masto-feed-parser.test.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`mastodon feed parser tests parse creates correct MD structure 1`] = ` +"--- +source: \\"https://chat.brainbaking.com/objects/77a3ecfb-47e1-4d7a-a24a-8b779d80a8ac\\" +context: \\"\\" +title: \\"I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-ri...\\" +date: \\"2021-03-01T19:03:35\\" +--- + +I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-rid-of-tracking-using-lineageos/ Very impressed so far! Also rely on my own CalDAV server to replace GCalendar. Any others here running #lineageos for privacy reasons? + " +`; diff --git a/test/expected-01h19m3s35.md b/test/expected-01h19m3s35.md deleted file mode 100644 index 406932a..0000000 --- a/test/expected-01h19m3s35.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: "https://chat.brainbaking.com/objects/77a3ecfb-47e1-4d7a-a24a-8b779d80a8ac" -context: "" -title: "I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-ri..." -date: "2021-03-01T19:03:35" ---- - -I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-rid-of-tracking-using-lineageos/ Very impressed so far! Also rely on my own CalDAV server to replace GCalendar. Any others here running #lineageos for privacy reasons? - \ No newline at end of file diff --git a/test/howlong-tobeat.test.js b/test/howlong-tobeat.test.js index 33ad1b7..88a897f 100644 --- a/test/howlong-tobeat.test.js +++ b/test/howlong-tobeat.test.js @@ -13,16 +13,6 @@ game_name: "Wizardry 8" blabla nice one 9/10 GG! ` -const expectedmd = `--- -title: "wizardry 8 review" -howlongtobeat_id: 11228 -howlongtobeat_hrs: 93 -game_name: "Wizardry 8" ---- - -blabla nice one 9/10 GG! -` - const dumpdir = `${__dirname}/howlong-stub` beforeEach(async () => { if(fs.existsSync(dumpdir)) { @@ -37,5 +27,5 @@ test('howlong adds howlong to beat id and hours to frontmatter', async () => { await howlong(dumpdir) const actualmd = await fsp.readFile(`${dumpdir}/howlongtobeat-sample.md`, 'utf-8') - expect(actualmd).toEqual(expectedmd) + expect(actualmd).toMatchSnapshot() }) diff --git a/test/masto-feed-parser.test.js b/test/masto-feed-parser.test.js index def72f0..59bf4cd 100644 --- a/test/masto-feed-parser.test.js +++ b/test/masto-feed-parser.test.js @@ -35,10 +35,8 @@ describe("mastodon feed parser tests", () => { notesdir: dumpdir }) - const actualMd = await fsp.readFile(`${dumpdir}/2021/03/01h19m3s35.md`).toString() - const expectedMd = await fsp.readFile(`${__dirname}/expected-01h19m3s35.md`).toString() - - expect(actualMd).toEqual(expectedMd) + const actualMd = (await fsp.readFile(`${dumpdir}/2021/03/01h19m3s35.md`)).toString() + expect(actualMd).toMatchSnapshot() }) test("parse creates MD with context if in-reply-to", async () => {