Skip to content

Commit b13a7c1

Browse files
authored
test: use consistent naming conventions (#31)
1 parent da233cf commit b13a7c1

File tree

7 files changed

+60
-58
lines changed

7 files changed

+60
-58
lines changed

src/model/collection/__tests__/periodic-log.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
33

44
import { PeriodicLog } from "../periodic-log";
55

6-
describe("PeriodicLog", () => {
6+
describe(PeriodicLog.name, () => {
77
describe("pre-conditions", () => {
88
it("should throw when folder is empty", () => {
99
expect(() => new PeriodicLog("", "yyyy-MM-dd", { days: 1 })).toThrow();

src/model/collection/__tests__/schema.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { describe, expect, it } from "vitest";
33

44
import { Collection } from "../schema";
55

6-
class TestCollection extends Collection {
7-
public override includes = constant(false);
8-
}
9-
10-
describe("Collection default implementations", () => {
6+
describe(Collection.name, () => {
117
it("returns invalid intervals", () => {
8+
class TestCollection extends Collection {
9+
public override includes = constant(false);
10+
}
11+
1212
expect(new TestCollection().getIntervalOf("path").isValid).toBe(false);
1313
});
1414
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { constant } from "lodash";
2+
3+
import { DataviewMarkdownTask } from "@/lib/obsidian-dataview/types";
4+
5+
export const NULL_DATAVIEW_TASK: DataviewMarkdownTask = {
6+
task: true,
7+
status: " ",
8+
checked: false,
9+
completed: false,
10+
fullyCompleted: false,
11+
symbol: "",
12+
link: undefined,
13+
section: {
14+
fileName: constant(undefined),
15+
obsidianLink: constant(undefined),
16+
subpath: undefined,
17+
},
18+
path: "",
19+
line: 0,
20+
lineCount: 0,
21+
position: {
22+
start: { line: 0, col: 0, offset: 0 },
23+
end: { line: 0, col: 0, offset: 0 },
24+
},
25+
list: 0,
26+
children: [],
27+
outlinks: [],
28+
text: "",
29+
tags: [],
30+
subtasks: [],
31+
real: false,
32+
header: undefined,
33+
} as const;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { constant } from "lodash";
22
import { afterEach, describe, expect, it, vi } from "vitest";
33

4-
import { DataviewMarkdownTask } from "@/lib/obsidian-dataview/types";
5-
64
import { adaptDataviewMarkdownTask } from "../obsidian-dataview";
5+
import { NULL_DATAVIEW_TASK } from "./obsidian-dataview.const";
76

8-
describe("Converting dataview tasks into objo tasks", () => {
7+
describe(adaptDataviewMarkdownTask.name, () => {
98
afterEach(() => vi.resetAllMocks());
109

1110
it.each([
@@ -27,33 +26,3 @@ describe("Converting dataview tasks into objo tasks", () => {
2726
expect(adaptDataviewMarkdownTask({ ...NULL_DATAVIEW_TASK, ...dataviewTaskPart })).toMatchObject(objoTaskPart);
2827
});
2928
});
30-
31-
const NULL_DATAVIEW_TASK: DataviewMarkdownTask = {
32-
task: true,
33-
status: " ",
34-
checked: false,
35-
completed: false,
36-
fullyCompleted: false,
37-
symbol: "",
38-
link: undefined,
39-
section: {
40-
fileName: constant(undefined),
41-
obsidianLink: constant(undefined),
42-
subpath: undefined,
43-
},
44-
path: "",
45-
line: 0,
46-
lineCount: 0,
47-
position: {
48-
start: { line: 0, col: 0, offset: 0 },
49-
end: { line: 0, col: 0, offset: 0 },
50-
},
51-
list: 0,
52-
children: [],
53-
outlinks: [],
54-
text: "",
55-
tags: [],
56-
subtasks: [],
57-
real: false,
58-
header: undefined,
59-
} as const;

src/model/task/lib/__tests__/obsidian-tasks.ts

+14-16
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { describe, expect, it } from "vitest";
33

44
import { parseTaskEmojiFormat } from "../obsidian-tasks";
55

6-
const isoDateTime = DateTime.fromISO;
7-
8-
describe("Parsing task emojis", () => {
6+
describe(parseTaskEmojiFormat.name, () => {
97
it.each([
108
[{ description: "task text" }, " \t task text \t "],
119
[{ priority: 0 }, "🔺"],
@@ -14,13 +12,13 @@ describe("Parsing task emojis", () => {
1412
[{ priority: 4 }, "🔽"],
1513
[{ priority: 5 }, "⏬"],
1614
[{ id: "due3rd", dependsOn: new Set(["due1st", "due2nd"]) }, "🆔 due3rd ⛔ due1st, due2nd"],
17-
[{ dates: { cancelled: isoDateTime("2024-10-25") } }, "❌ 2024-10-25"],
18-
[{ dates: { created: isoDateTime("2024-10-26") } }, "➕ 2024-10-26"],
19-
[{ dates: { done: isoDateTime("2024-10-27") } }, "✅ 2024-10-27"],
20-
[{ dates: { due: isoDateTime("2024-10-28") } }, "📅 2024-10-28"],
21-
[{ dates: { scheduled: isoDateTime("2024-10-29") } }, "⏳ 2024-10-29"],
22-
[{ dates: { scheduled: isoDateTime("2024-10-30") } }, "⏳ 2024-10-30"],
23-
[{ dates: { start: isoDateTime("2024-10-31") } }, "🛫 2024-10-31"],
15+
[{ dates: { cancelled: DateTime.fromISO("2024-10-25") } }, "❌ 2024-10-25"],
16+
[{ dates: { created: DateTime.fromISO("2024-10-26") } }, "➕ 2024-10-26"],
17+
[{ dates: { done: DateTime.fromISO("2024-10-27") } }, "✅ 2024-10-27"],
18+
[{ dates: { due: DateTime.fromISO("2024-10-28") } }, "📅 2024-10-28"],
19+
[{ dates: { scheduled: DateTime.fromISO("2024-10-29") } }, "⏳ 2024-10-29"],
20+
[{ dates: { scheduled: DateTime.fromISO("2024-10-30") } }, "⏳ 2024-10-30"],
21+
[{ dates: { start: DateTime.fromISO("2024-10-31") } }, "🛫 2024-10-31"],
2422
])("parses %j from input=%j", (taskPart, text) => {
2523
expect(parseTaskEmojiFormat(text)).toMatchObject(taskPart);
2624
});
@@ -42,12 +40,12 @@ describe("Parsing task emojis", () => {
4240
id: "do3rd",
4341
dependsOn: new Set(["do1st", "do2nd"]),
4442
dates: {
45-
cancelled: isoDateTime("2024-10-25"),
46-
created: isoDateTime("2024-10-26"),
47-
done: isoDateTime("2024-10-27"),
48-
due: isoDateTime("2024-10-28"),
49-
scheduled: isoDateTime("2024-10-29"),
50-
start: isoDateTime("2024-10-30"),
43+
cancelled: DateTime.fromISO("2024-10-25"),
44+
created: DateTime.fromISO("2024-10-26"),
45+
done: DateTime.fromISO("2024-10-27"),
46+
due: DateTime.fromISO("2024-10-28"),
47+
scheduled: DateTime.fromISO("2024-10-29"),
48+
start: DateTime.fromISO("2024-10-30"),
5149
},
5250
});
5351
});

src/model/task/util/__tests__/merge.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
33

44
import { mergeTaskParts } from "../merge";
55

6-
describe("Merging task parts", () => {
6+
describe(mergeTaskParts.name, () => {
77
it("gives default values when called with nothing", () => {
88
const task = mergeTaskParts();
99

src/util/__tests__/type-utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { describe, expectTypeOf, it } from "vitest";
22

33
import { PathsOf } from "../type-utils";
44

5-
describe("PathOf", () => {
5+
describe("PathsOf", () => {
66
it("returns the type of the first property of an object", () => {
7-
expectTypeOf<PathsOf<{ a: { b: { c: string } } }>>().toEqualTypeOf<"a" | "a.b" | "a.b.c">();
7+
type Obj = { a: { b: { c: string } } };
8+
9+
expectTypeOf<PathsOf<Obj>>().toEqualTypeOf<"a" | "a.b" | "a.b.c">();
810
});
911
});

0 commit comments

Comments
 (0)