[Indiekit] Add fixture helpers

I can't quite get my head around how @indiekit-test/fixtures is available to the tests in the official indiekit repo, so I've copied it here for now.
This commit is contained in:
JP Hastings-Spital 2024-10-08 12:13:23 +01:00
parent 62bc8321db
commit f90ecd1dcd
45 changed files with 435 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

View file

@ -0,0 +1,11 @@
<html>
<head>
<title>Client (with microformats2)</title>
</head>
<body>
<h1 class="h-app p-name">Simple client example</h1>
</body>
</html>

View file

@ -0,0 +1,21 @@
<html>
<head>
<title>Client (with microformats2)</title>
</head>
<body>
<!-- Link to another client, marked up using h-x-app -->
<p class="h-x-app">
<a class="u-url p-name" href="https://another.example">Another client</a>
</p>
<!-- Logo linking to homepage of this client, marked up using h-x-app -->
<p class="h-x-app">
<a class="u-url p-name" href="/">
<img class="u-logo p-name" src="/assets/icon.svg" alt="Example client">
</a>
</p>
</body>
</html>

View file

@ -0,0 +1,11 @@
<html>
<head>
<title>Page (without microformats2)</title>
</head>
<body>
<p>I ate a cheese sandwich, which was nice.</p>
</body>
</html>

View file

@ -0,0 +1,14 @@
<html>
<head>
<title>Post (with microformats2)</title>
</head>
<body>
<article class="h-entry">
<time class="dt-published">2013-03-07</time>:
<p class="p-name p-content">I ate a <em>cheese</em> sandwich, which was nice.</p>
</article>
</body>
</html>

View file

@ -0,0 +1,14 @@
import fs from "node:fs";
import { fileURLToPath } from "node:url";
/**
* @param {string} filename - Fixtures file name
* @param {boolean} utf8 - Encoding fixture as UTF8
* @returns {object} File contents
*/
export const getFixture = (filename, utf8 = true) => {
const file = fileURLToPath(new URL(filename, import.meta.url));
return fs.readFileSync(file, {
...(utf8 && { encoding: "utf8" }),
});
};

View file

@ -0,0 +1,40 @@
{
"type": "entry",
"url": "https://website.example/posts/cheese-sandwich",
"name": "What I had for lunch",
"content": {
"html": "<p>I ate a <a href=\"https://en.wikipedia.org/wiki/Cheese\">cheese</a> sandwich, which was nice.</p>",
"text": "I ate a [cheese](https://en.wikipedia.org/wiki/Cheese) sandwich, which was nice."
},
"summary": "A very satisfactory meal.",
"published": "2020-02-02",
"category": ["lunch", "food"],
"audio": [{
"url": "https://website.example/audio.mp3"
}],
"photo": [{
"alt": "Alternative text",
"url": "https://website.example/photo.jpg"
}],
"video": [{
"url": "https://website.example/video.mp4"
}],
"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"
},
"bookmark-of": "https://website.example",
"like-of": "https://website.example",
"repost-of": "https://website.example",
"in-reply-to": "https://website.example",
"post-status": "draft",
"visibility": "private",
"syndication": "https://website.example/post/12345",
"mp-slug": "cheese-sandwich",
"mp-syndicate-to": "https://mastodon.example"
}

View file

@ -0,0 +1,4 @@
{
"type": "entry",
"name": "What I had for lunch"
}

View file

@ -0,0 +1,9 @@
{
"type": "entry",
"name": "What I had for lunch",
"content": {
"html": "<blockquote><p>I <del>ate</del><ins>had</ins> a <cite><a href=\"https://en.wikipedia.org/wiki/Cheese\">cheese</a></cite> sandwich from <a href=\"https://cafe.example\">https://cafe.example</a>, which was &gt; 10.</p></blockquote><p> Me, then.</p>",
"text": "> I <del>ate</del><ins>had</ins> a <cite>[cheese](https://en.wikipedia.org/wiki/Cheese)</cite> sandwich from https://cafe.example, which was > 10.\n\n-- Me, then."
},
"url": "https://foo.bar/lunchtime"
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"name": "What I had for lunch",
"content": {
"html": "<blockquote><p>I <del>ate</del><ins>had</ins> a <cite><a href=\"https://en.wikipedia.org/wiki/Cheese\">cheese</a></cite> sandwich from <a href=\"https://cafe.example\">https://cafe.example</a>, which was &gt; 10.</p></blockquote><p> Me, then.</p>"
},
"url": "https://foo.bar/lunchtime"
}

View file

@ -0,0 +1,7 @@
{
"type": "entry",
"name": "What I had for lunch",
"content": {
"text": "> I <del>ate</del><ins>had</ins> a <cite>[cheese](https://en.wikipedia.org/wiki/Cheese)</cite> sandwich from https://cafe.example, which was > 10.\n\n-- Me, then."
}
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"name": "What I had for lunch",
"content": "> I <del>ate</del><ins>had</ins> a <cite>[cheese](https://en.wikipedia.org/wiki/Cheese)</cite> sandwich from https://cafe.example, which was > 10.\n\n-- Me, then."
}

View file

@ -0,0 +1,6 @@
{
"type": "entry",
"name": "What I had for lunch",
"content": "I ate a *cheese* sandwich, which was nice.",
"mp-slug": ""
}

View file

@ -0,0 +1,6 @@
{
"type": "entry",
"name": "What I had for lunch",
"content": "I ate a *cheese* sandwich, which was nice.",
"mp-syndicate-to": ["https://example.website/"]
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"name": "Audio",
"audio": "https://website.example/baz.mp3"
}

View file

@ -0,0 +1,9 @@
{
"type": "entry",
"name": "Audio",
"audio": [{
"url": "https://website.example/baz.mp3"
}, {
"url": "https://foo.bar/qux.mp3"
}]
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"name": "Audio",
"audio": [
"https://website.example/baz.mp3",
"https://foo.bar/qux.mp3"
]
}

View file

@ -0,0 +1,13 @@
{
"type": "feed",
"name": "My Example Feed",
"summary": "A description of my example feed",
"url": "https://website.example/",
"photo": "https://website.example/icon.png",
"author": {
"name": "Jane Doe",
"url": "https://website.example/~janedoe",
"avatar": "https://website.example/~janedoe/photo.jpg"
},
"children": []
}

View file

@ -0,0 +1,54 @@
{
"type": "feed",
"name": "My Example Feed",
"summary": "A description of my example feed",
"url": "https://website.example/",
"photo": "https://website.example/icon.png",
"author": {
"name": "Jane Doe",
"url": "https://website.example/~janedoe",
"avatar": "https://website.example/~janedoe/photo.jpg"
},
"children": [{
"type": "entry",
"uid": "https://website.example/second-item",
"url": "https://website.example/second-item",
"name": "Second item in feed",
"content": {
"text": "This second item has all fields.",
"html": "<p>This second item has <strong>all</strong> fields.</p>"
},
"summary": "This is the second item",
"featured": "https://another.example/banner_image.jpg",
"published": "2020-12-31T17:05:55+00:00",
"updated": "2021-01-01T12:05:55+00:00",
"author": {
"name": "Joe Bloggs",
"url": "https://website.example/~joebloggs",
"photo": "https://website.example/~joebloggs/photo.jpg"
},
"category": ["second", "example"],
"audio": [{
"url": "https://website.example/second-item/audio.weba",
"alt": "Audio",
"content-type": "audio/webm"
}],
"photo": [{
"url": "https://website.example/second-item/photo.webp",
"alt": "Photo",
"content-type": "image/webp"
}],
"video": [{
"url": "https://website.example/second-item/audio.webm",
"alt": "Video",
"content-type": "video/webm"
}]
}, {
"type": "entry",
"uid": "https://website.example/first-item/",
"url": "https://website.example/first-item/",
"content": {
"text": "This first item has only the required fields."
}
}]
}

View file

@ -0,0 +1,6 @@
{
"type": "entry",
"content": {
"html": "<blockquote><p>I ate a <a href=\"https://en.wikipedia.org/wiki/Cheese\">cheese</a> sandwich, which was &gt; 10.</p></blockquote>"
}
}

View file

@ -0,0 +1,6 @@
{
"type": "entry",
"content": {
"html": "<p>I ate <a href=\"https://mastodon.example/@cheese\">@cheese</a>s sandwich, which was nice.</p>"
}
}

View file

@ -0,0 +1,7 @@
{
"type": "entry",
"content": {
"html": "<blockquote><p>I ate a <i>cheese</i> sandwich, which was &gt; 10.</p></blockquote>"
},
"url": "https://foo.bar/lunchtime"
}

View file

@ -0,0 +1,13 @@
{
"type": "entry",
"content": {
"html": "<p>I ate a cheese sandwich right here!</p>",
"text": "I ate a cheese sandwich right here!"
},
"location": {
"type": "geo",
"latitude": "37.780080",
"longitude": "-122.420160",
"name": "37° 46 48.29″ N 122° 25 12.576″ W"
}
}

View file

@ -0,0 +1,4 @@
{
"type": "entry",
"content": "I ate a cheese sandwich, which was nice."
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"content": "I ate a cheese sandwich, which was nice.",
"published": "2019-01-02"
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"content": "I ate a cheese sandwich, which was nice.",
"published": "2019-01-02T03:04:05.678Z"
}

View file

@ -0,0 +1,4 @@
{
"type": "entry",
"content": "I ate a cheese sandwich, which was nice."
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"content": "I ate a cheese sandwich, which was nice.",
"mp-slug": "Cheese sandwich"
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"content": "I ate a cheese sandwich, which was nice.",
"mp-slug": "cheese-sandwich"
}

View file

@ -0,0 +1,7 @@
{
"type": "entry",
"content": {
"html": "<p>I ate a cheese sandwich, which was nice.</p>"
},
"visibility": "unlisted"
}

View file

@ -0,0 +1,9 @@
{
"type": "entry",
"name": "Photo",
"photo": [
"https://website.example/baz.jpg",
"https://foo.bar/qux.jpg"
],
"mp-photo-alt": ["Baz", "Qux"]
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"name": "Photo",
"photo": "https://website.example/baz.jpg"
}

View file

@ -0,0 +1,11 @@
{
"type": "entry",
"name": "Photo",
"photo": [{
"alt": "Baz",
"url": "https://website.example/baz.jpg"
}, {
"alt": " Qux ",
"url": "https://foo.bar/qux.jpg"
}]
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"name": "Photo",
"photo": [
"https://website.example/baz.jpg",
"https://foo.bar/qux.jpg"
]
}

View file

@ -0,0 +1,37 @@
{
"type": "entry",
"url": "https://website.example/posts/cheese-sandwich",
"name": "What I had for lunch",
"content": {
"html": "<p>I ate a <a href=\"https://en.wikipedia.org/wiki/Cheese\">cheese</a> sandwich, which was nice.</p>",
"text": "I ate a [cheese](https://en.wikipedia.org/wiki/Cheese) sandwich, which was nice."
},
"summary": "A very satisfactory meal.",
"published": "2020-02-02",
"category": ["lunch", "food"],
"audio": [{
"url": "https://website.example/audio.mp3"
}],
"photo": [{
"alt": "Alternative text",
"url": "https://website.example/photo.jpg"
}],
"video": [{
"url": "https://website.example/video.mp4"
}],
"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"
},
"bookmark-of": "https://website.example",
"like-of": "https://website.example",
"repost-of": "https://website.example",
"in-reply-to": "https://website.example",
"visibility": "private",
"syndication": "https://website.example/post/12345"
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"content": {
"html": "<p>I ate a cheese sandwich too!</p>",
"text": "I ate a cheese sandwich too!"
},
"in-reply-to": "https://mastodon.example/@username/1234567890987654321"
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"content": {
"html": "<p>I ate a cheese sandwich too!</p>",
"text": "I ate a cheese sandwich too!"
},
"in-reply-to": "https://deadbird.example/username/1234567890987654321"
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"content": {
"html": "<p>Someone else who likes cheese sandwiches.</p>",
"text": "Someone else who likes cheese sandwiches."
},
"repost-of": "https://mastodon.example/@username/1234567890987654321"
}

View file

@ -0,0 +1,5 @@
{
"type": "entry",
"name": "Video",
"video": "https://website.example/baz.mp4"
}

View file

@ -0,0 +1,9 @@
{
"type": "entry",
"name": "Video",
"video": [{
"url": "https://website.example/baz.mp4"
}, {
"url": "https://foo.bar/qux.mp4"
}]
}

View file

@ -0,0 +1,8 @@
{
"type": "entry",
"name": "Video",
"video": [
"https://website.example/baz.mp4",
"https://foo.bar/qux.mp4"
]
}

View file

@ -0,0 +1,7 @@
{
"name": "@indiekit-test/fixtures",
"main": "index.js",
"type": "module",
"private": true,
"license": "MIT"
}