Skip to content

Commit

Permalink
chore: get 100% test coverage on find-page.js
Browse files Browse the repository at this point in the history
  • Loading branch information
carbontwelve committed May 1, 2024
1 parent ac4e45a commit 7d541b5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/find-page-service.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const test = require("ava");
const {pageLookup} = require("../src/find-page");
const slugify = require("slugify");

const pageDirectory = pageLookup([
{
fileSlug: 'hello-world',
data: {
title: 'Hello World, Title',
aliases: null
},
url: '/hello-world/'
},
{
fileSlug: 'hello-world-1',
data: {
title: 'Hello World, One Title',
aliases: [],
},
url: '/hello-world/1/'
},
{
fileSlug: 'something-else',
data: {
title: 'This is another page',
aliases: ['test-alias']
},
url: '/something/else/'
}
], slugify);

test('pageLookup (find by href)', t => {
t.is(pageDirectory.findByLink({href: '/something/else', isEmbed: false}).fileSlug, 'something-else');
});

test('pageLookup (find by wikilink)', t => {
t.is(pageDirectory.findByLink({
title: 'Hello World, Title',
name: 'hello-world',
anchor: null,
link: '[[hello-world]]',
slug: 'hello-world',
isEmbed: false,
}).fileSlug, 'hello-world');
});

test('pageLookup (find by alias)', t => {
t.is(pageDirectory.findByLink({
title: 'This is another page',
name: 'test-alias',
anchor: null,
link: '[[test-alias]]',
slug: 'test-alias',
isEmbed: false,
}).fileSlug, 'something-else');
});

0 comments on commit 7d541b5

Please sign in to comment.