-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(preset-jekyll): use node test runner
- Loading branch information
1 parent
6cc831d
commit 96648bb
Showing
2 changed files
with
136 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import { strict as assert } from "node:assert"; | ||
import { describe, it } from "node:test"; | ||
import { Indiekit } from "@indiekit/indiekit"; | ||
import { getFixture } from "@indiekit-test/fixtures"; | ||
import JekyllPreset from "../index.js"; | ||
|
||
describe("preset-jekyll", () => { | ||
const jekyll = new JekyllPreset(); | ||
|
||
const properties = JSON.parse(getFixture("jf2/all-properties.jf2")); | ||
|
||
it("Gets plug-in info", () => { | ||
assert.equal(jekyll.name, "Jekyll preset"); | ||
assert.equal(jekyll.info.name, "Jekyll"); | ||
}); | ||
|
||
it("Initiates plug-in", async () => { | ||
const indiekit = await Indiekit.initialize({ config: {} }); | ||
jekyll.init(indiekit); | ||
|
||
assert.equal(indiekit.publication.preset.info.name, "Jekyll"); | ||
}); | ||
|
||
it("Gets publication post types", () => { | ||
const result = jekyll.postTypes; | ||
|
||
assert.equal(result[0].type, "article"); | ||
}); | ||
|
||
it("Renders post template without content", () => { | ||
const result = jekyll.postTemplate({ | ||
published: "2020-02-02", | ||
updated: "2022-12-11", | ||
deleted: "2022-12-12", | ||
name: "Lunchtime", | ||
}); | ||
|
||
assert.equal( | ||
result, | ||
`--- | ||
date: 2020-02-02 | ||
updated: 2022-12-11 | ||
deleted: 2022-12-12 | ||
title: Lunchtime | ||
--- | ||
`, | ||
); | ||
}); | ||
|
||
it("Renders post template with basic content", () => { | ||
const result = jekyll.postTemplate({ | ||
published: "2020-02-02", | ||
name: "Lunchtime", | ||
content: | ||
"I ate a [cheese](https://en.wikipedia.org/wiki/Cheese) sandwich, which was nice.", | ||
}); | ||
|
||
assert.equal( | ||
result, | ||
`--- | ||
date: 2020-02-02 | ||
title: Lunchtime | ||
--- | ||
I ate a [cheese](https://en.wikipedia.org/wiki/Cheese) sandwich, which was nice. | ||
`, | ||
); | ||
}); | ||
|
||
it("Renders post template with HTML content", () => { | ||
const result = jekyll.postTemplate({ | ||
published: "2020-02-02", | ||
name: "Lunchtime", | ||
content: { | ||
html: '<p>I ate a <a href="https://en.wikipedia.org/wiki/Cheese">cheese</a> sandwich, which was nice.</p>', | ||
}, | ||
}); | ||
|
||
assert.equal( | ||
result, | ||
`--- | ||
date: 2020-02-02 | ||
title: Lunchtime | ||
--- | ||
<p>I ate a <a href="https://en.wikipedia.org/wiki/Cheese">cheese</a> sandwich, which was nice.</p> | ||
`, | ||
); | ||
}); | ||
|
||
it("Renders post template", () => { | ||
const jekyll = new JekyllPreset(); | ||
const result = jekyll.postTemplate(properties); | ||
|
||
assert.equal( | ||
result, | ||
`--- | ||
date: 2020-02-02 | ||
title: What I had for lunch | ||
excerpt: A very satisfactory meal. | ||
category: | ||
- lunch | ||
- food | ||
start: 2020-02-02 | ||
end: 2020-02-20 | ||
rsvp: Yes | ||
location: | ||
type: geo | ||
latitude: "37.780080" | ||
longitude: "-122.420160" | ||
name: 37° 46′ 48.29″ N 122° 25′ 12.576″ W | ||
checkin: | ||
type: card | ||
latitude: "50" | ||
longitude: "0" | ||
audio: | ||
- url: https://website.example/audio.mp3 | ||
photo: | ||
- alt: Alternative text | ||
url: https://website.example/photo.jpg | ||
video: | ||
- url: https://website.example/video.mp4 | ||
bookmark-of: https://website.example | ||
like-of: https://website.example | ||
repost-of: https://website.example | ||
in-reply-to: https://website.example | ||
published: false | ||
visibility: private | ||
syndication: https://website.example/post/12345 | ||
--- | ||
I ate a [cheese](https://en.wikipedia.org/wiki/Cheese) sandwich, which was nice. | ||
`, | ||
); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.