@@ -9,6 +9,7 @@ describe("Note", function()
9
9
assert .equals (note .id , " FOO" )
10
10
assert .equals (note .aliases [1 ], " foo" )
11
11
end )
12
+
12
13
it (" should be able to be initialized from a file" , function ()
13
14
local note = Note .from_file " test_fixtures/notes/foo.md"
14
15
assert .equals (note .id , " foo" )
@@ -18,13 +19,15 @@ describe("Note", function()
18
19
assert .is_true (note .has_frontmatter )
19
20
assert (# note .tags == 0 )
20
21
end )
22
+
21
23
it (" should be able to be initialized from a README" , function ()
22
24
local note = Note .from_file " README.md"
23
25
assert .equals (note .id , " README" )
24
26
assert .equals (# note .tags , 0 )
25
27
assert .equals (note :fname (), " README.md" )
26
28
assert .is_false (note :should_save_frontmatter ())
27
29
end )
30
+
28
31
it (" should be able to be initialized from a note w/o frontmatter" , function ()
29
32
local note = Note .from_file " test_fixtures/notes/note_without_frontmatter.md"
30
33
assert .equals (note .id , " note_without_frontmatter" )
@@ -35,32 +38,39 @@ describe("Note", function()
35
38
assert .is_false (note .has_frontmatter )
36
39
assert .is_true (note :should_save_frontmatter ())
37
40
end )
41
+
38
42
it (" should be able to add an alias" , function ()
39
43
local note = Note .from_file " test_fixtures/notes/foo.md"
40
44
assert .equals (# note .aliases , 2 )
41
45
note :add_alias " Foo Bar"
42
46
assert .equals (# note .aliases , 3 )
43
47
end )
48
+
44
49
it (" should be able to save to file" , function ()
45
50
local note = Note .from_file " test_fixtures/notes/foo.md"
46
51
note :add_alias " Foo Bar"
47
52
note :save " ./test_fixtures/notes/foo_bar.md"
48
53
end )
54
+
49
55
it (" should be able to save note w/o frontmatter to file" , function ()
50
56
local note = Note .from_file " test_fixtures/notes/note_without_frontmatter.md"
51
57
note :save " ./test_fixtures/notes/note_without_frontmatter_saved.md"
52
58
end )
59
+
53
60
it (" should be able to save a new note" , function ()
54
61
local note = Note .new (" FOO" , {}, {}, " /tmp/" .. util .zettel_id () .. " .md" )
55
62
note :save ()
56
63
end )
64
+
57
65
it (" should be able to parse a markdown header" , function ()
58
66
assert .equals (Note ._parse_header " ## Hey there" , " Hey there" )
59
67
end )
68
+
60
69
it (" should be able to find a frontmatter boundary" , function ()
61
70
assert .is_true (Note ._is_frontmatter_boundary " ---" )
62
71
assert .is_true (Note ._is_frontmatter_boundary " ----" )
63
72
end )
73
+
64
74
it (" should be able to be initialize and save a note with additional frontmatter metadata" , function ()
65
75
local note = Note .from_file " test_fixtures/notes/note_with_additional_metadata.md"
66
76
assert .equals (note .id , " note_with_additional_metadata" )
@@ -80,6 +90,7 @@ describe("Note", function()
80
90
)
81
91
note :save " ./test_fixtures/notes/note_with_additional_metadata_saved.md"
82
92
end )
93
+
83
94
it (" should be able to be read frontmatter that's formatted differently" , function ()
84
95
local note = Note .from_file " test_fixtures/notes/note_with_different_frontmatter_format.md"
85
96
assert .equals (note .id , " note_with_different_frontmatter_format" )
0 commit comments