attempt to fix test at github-side
This commit is contained in:
parent
5d571f4ffd
commit
62d16df57a
|
@ -7,34 +7,35 @@ const frontMatterParser = require('parser-front-matter');
|
||||||
jest.mock('got');
|
jest.mock('got');
|
||||||
|
|
||||||
const { parseMastoFeed } = require('../src/masto-feed-parser')
|
const { parseMastoFeed } = require('../src/masto-feed-parser')
|
||||||
|
const dumpdir = `${__dirname}/dump`
|
||||||
|
|
||||||
describe("mastodon feed parser tests", () => {
|
describe("mastodon feed parser tests", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
if(fs.existsSync("dump")) {
|
if(fs.existsSync(dumpdir)) {
|
||||||
rmdir("dump")
|
rmdir(dumpdir)
|
||||||
}
|
}
|
||||||
fs.mkdirSync("dump")
|
fs.mkdirSync(dumpdir)
|
||||||
});
|
});
|
||||||
|
|
||||||
test("parse creates separate notes in each month subdir", async () => {
|
test("parse creates separate notes in each month subdir", async () => {
|
||||||
await parseMastoFeed({
|
await parseMastoFeed({
|
||||||
url: "invalid",
|
url: "invalid",
|
||||||
notesdir: "dump"
|
notesdir: dumpdir
|
||||||
})
|
})
|
||||||
|
|
||||||
let dir = await fsp.readdir("dump/2021/02", { withFileTypes: true })
|
let dir = await fsp.readdir(`${dumpdir}/2021/02`, { withFileTypes: true })
|
||||||
expect(dir.length).toBe(8)
|
expect(dir.length).toBe(8)
|
||||||
dir = await fsp.readdir("dump/2021/03", { withFileTypes: true })
|
dir = await fsp.readdir(`${dumpdir}/2021/03`, { withFileTypes: true })
|
||||||
expect(dir.length).toBe(4)
|
expect(dir.length).toBe(4)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("parse creates correct MD structure", async () => {
|
test("parse creates correct MD structure", async () => {
|
||||||
await parseMastoFeed({
|
await parseMastoFeed({
|
||||||
url: "invalid",
|
url: "invalid",
|
||||||
notesdir: "dump"
|
notesdir: dumpdir
|
||||||
})
|
})
|
||||||
|
|
||||||
const actualMd = await fsp.readFile(`${__dirname}/../dump/2021/03/01h20m3s35.md`).toString()
|
const actualMd = await fsp.readFile(`${dumpdir}/2021/03/01h20m3s35.md`).toString()
|
||||||
const expectedMd = await fsp.readFile(`${__dirname}/expected-01h20m3s35.md`).toString()
|
const expectedMd = await fsp.readFile(`${__dirname}/expected-01h20m3s35.md`).toString()
|
||||||
|
|
||||||
expect(actualMd).toEqual(expectedMd)
|
expect(actualMd).toEqual(expectedMd)
|
||||||
|
@ -44,10 +45,10 @@ describe("mastodon feed parser tests", () => {
|
||||||
//https://aus.social/users/aussocialadmin/statuses/105817435308293091
|
//https://aus.social/users/aussocialadmin/statuses/105817435308293091
|
||||||
await parseMastoFeed({
|
await parseMastoFeed({
|
||||||
url: "invalid",
|
url: "invalid",
|
||||||
notesdir: "dump"
|
notesdir: dumpdir
|
||||||
})
|
})
|
||||||
|
|
||||||
const actualMd = await fsp.readFile(`${__dirname}/../dump/2021/03/02h17m18s46.md`)
|
const actualMd = await fsp.readFile(`${dumpdir}/2021/03/02h17m18s46.md`)
|
||||||
const expectedReplyTo = "https://social.linux.pizza/users/StampedingLonghorn/statuses/105821099684887793"
|
const expectedReplyTo = "https://social.linux.pizza/users/StampedingLonghorn/statuses/105821099684887793"
|
||||||
|
|
||||||
const md = frontMatterParser.parseSync(actualMd.toString())
|
const md = frontMatterParser.parseSync(actualMd.toString())
|
||||||
|
|
Loading…
Reference in New Issue