Skip to content

Commit af76c68

Browse files
committed
fixing unit tests
1 parent 76b74d3 commit af76c68

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

src/errors/NotFoundError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class NotFoundError extends Error {
55
private _cause: Error;
66
constructor(rootDir: string, type: string, slug: string, cause: Error) {
77
super(
8-
`Content Not Found, rootDir = ${rootDir}, type = ${type}, slug = ${slug}`
8+
`Content Not Found, rootDir = ${rootDir}, type = ${type}, slug = ${slug}`
99
);
1010
this._rootDir = rootDir;
1111
this._type = type;

tests/__snapshots__/getContent.test.ts.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Check only metadata is returned when there is no content 1`] = `
4-
{
5-
"category": "Marketing",
6-
"content": "",
7-
"priceRange": "$800 - $4000",
8-
"slug": "service-2",
9-
"tags": [
10-
"digital marketing",
11-
"services",
12-
],
13-
"title": "Digital Marketing Strategy",
14-
"type": "service",
15-
}
16-
`;
17-
183
exports[`Get content With Seo with default value for non existing seo key 1`] = `
194
{
205
"_seoMetaTags": [
@@ -151,7 +136,22 @@ Closures are an important concept in JavaScript, enabling powerful patterns for
151136
}
152137
`;
153138

154-
exports[`return full content when no attributes specified 1`] = `
139+
exports[`getContent Tests Check only metadata is returned when there is no content 1`] = `
140+
{
141+
"category": "Marketing",
142+
"content": "",
143+
"priceRange": "$800 - $4000",
144+
"slug": "service-2",
145+
"tags": [
146+
"digital marketing",
147+
"services",
148+
],
149+
"title": "Digital Marketing Strategy",
150+
"type": "service",
151+
}
152+
`;
153+
154+
exports[`getContent Tests return full content when no attributes specified 1`] = `
155155
{
156156
"category": "Electronics",
157157
"content": "# SuperFast Laptop

tests/__snapshots__/listContent.test.ts.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -443,49 +443,49 @@ exports[`listContent Tests Sort 1`] = `
443443
exports[`listContent Tests return title of all slugs 1`] = `
444444
[
445445
{
446-
"title": "Understanding JavaScript Closures",
446+
"title": "Cloud Hosting Solutions",
447447
},
448448
{
449-
"title": "The Future of AI in Healthcare",
449+
"title": "Digital Marketing Strategy",
450450
},
451451
{
452-
"title": "How to Improve Your CSS Skills",
452+
"title": "Eco-Friendly Water Bottle",
453453
},
454454
{
455-
"title": undefined,
455+
"title": "Electric Standing Desk using Javascript",
456456
},
457457
{
458-
"title": "Special @#$% Characters!",
458+
"title": "How to Improve Your CSS Skills",
459459
},
460460
{
461-
"title": "SuperFast Laptop",
461+
"title": "Mobile App Development",
462462
},
463463
{
464-
"title": "Eco-Friendly Water Bottle",
464+
"title": "Noise-Canceling Headphones",
465465
},
466466
{
467-
"title": "Noise-Canceling Headphones",
467+
"title": "SEO Optimization using Javascript",
468468
},
469469
{
470470
"title": "Smart Home Security System",
471471
},
472472
{
473-
"title": "Electric Standing Desk using Javascript",
473+
"title": "Special @#$% Characters!",
474474
},
475475
{
476-
"title": "Website Development",
476+
"title": "SuperFast Laptop",
477477
},
478478
{
479-
"title": "Digital Marketing Strategy",
479+
"title": "The Future of AI in Healthcare",
480480
},
481481
{
482-
"title": "SEO Optimization using Javascript",
482+
"title": "Understanding JavaScript Closures",
483483
},
484484
{
485-
"title": "Mobile App Development",
485+
"title": undefined,
486486
},
487487
{
488-
"title": "Cloud Hosting Solutions",
488+
"title": "Website Development",
489489
},
490490
]
491491
`;

tests/getContent.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ describe("getContent Tests", () => {
4949
test("Handle non-existent type", async () => {
5050
Config.setRootDir(commonRootDir);
5151
await expect(getContent("files", "blog-1")).rejects.toThrow(
52-
"Content Not Found, type = files, slug = blog-1"
52+
"Content Not Found, rootDir = " +
53+
commonRootDir +
54+
", type = files, slug = blog-1"
5355
);
5456
});
5557
test("Handle non-existent slug", async () => {

tests/listContent.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe("listContent Tests", () => {
2323
test("return title of all slugs", async () => {
2424
Config.setRootDir(commonRootDir);
2525
const slug = await listContent({}, ["title"]);
26+
slug.sort((a, b) => (a.title as string)?.localeCompare(b.title as string));
2627
expect(slug).toMatchSnapshot();
2728
});
2829
test("Filter content matching in title", async () => {

0 commit comments

Comments
 (0)