@@ -45,10 +45,16 @@ func TestFSNoteWriter_WriteNote_BasicNote(t *testing.T) {
4545 content , err := os .ReadFile (filepath .Join (base , relPath ))
4646 require .NoError (t , err )
4747
48- assert .Contains (t , string (content ), "---" )
49- assert .Contains (t , string (content ), `title: "My Note"` )
50- assert .Contains (t , string (content ), `account: "iCloud"` )
51- assert .Contains (t , string (content ), "Hello world" )
48+ s := string (content )
49+ // Title as heading at the top.
50+ assert .True (t , strings .HasPrefix (s , "# My Note\n " ))
51+ // Body content.
52+ assert .Contains (t , s , "Hello world" )
53+ // Metadata table at the bottom with divider.
54+ assert .Contains (t , s , "\n ---\n " )
55+ assert .Contains (t , s , "| ID | Created | Modified | Account | Shared |" )
56+ assert .Contains (t , s , "| x-coredata://test-id |" )
57+ assert .Contains (t , s , "| iCloud |" )
5258}
5359
5460func TestFSNoteWriter_WriteNote_WithSubdir (t * testing.T ) {
@@ -61,7 +67,7 @@ func TestFSNoteWriter_WriteNote_WithSubdir(t *testing.T) {
6167 assert .Equal (t , filepath .Join ("notes" , "Work" , "Test.md" ), relPath )
6268}
6369
64- func TestFSNoteWriter_WriteNote_NoFrontMatter (t * testing.T ) {
70+ func TestFSNoteWriter_WriteNote_NoMetadata (t * testing.T ) {
6571 w , base := newTestWriter (t , "" , false )
6672
6773 note := newTestNote ("Simple" , "Notes" , "Just content\n " )
@@ -71,8 +77,12 @@ func TestFSNoteWriter_WriteNote_NoFrontMatter(t *testing.T) {
7177 content , err := os .ReadFile (filepath .Join (base , relPath ))
7278 require .NoError (t , err )
7379
74- assert .NotContains (t , string (content ), "---" )
75- assert .Equal (t , "Just content\n " , string (content ))
80+ s := string (content )
81+ // Title heading is always present.
82+ assert .True (t , strings .HasPrefix (s , "# Simple\n " ))
83+ assert .Contains (t , s , "Just content" )
84+ // No metadata table.
85+ assert .NotContains (t , s , "| ID |" )
7686}
7787
7888func TestFSNoteWriter_WriteNote_NestedFolders (t * testing.T ) {
@@ -199,25 +209,38 @@ func TestFSNoteWriter_SaveAttachment_NilData(t *testing.T) {
199209 assert .Empty (t , relPath )
200210}
201211
202- func TestEscapeFrontMatterString (t * testing.T ) {
203- assert .Equal (t , `Hello \"World\"` , escapeFrontMatterString (`Hello "World"` ))
204- assert .Equal (t , "No quotes" , escapeFrontMatterString ("No quotes" ))
212+ func TestFSNoteWriter_WriteNote_MetadataTableContent (t * testing.T ) {
213+ w , base := newTestWriter (t , "" , true )
214+
215+ note := newTestNote ("My Title" , "Notes" , "Body\n " )
216+ note .Shared = true
217+ relPath , err := w .WriteNote (context .Background (), & note )
218+ require .NoError (t , err )
219+
220+ content , err := os .ReadFile (filepath .Join (base , relPath ))
221+ require .NoError (t , err )
222+
223+ s := string (content )
224+ // Title heading at top.
225+ assert .True (t , strings .HasPrefix (s , "# My Title\n " ))
226+ // Body before divider.
227+ assert .Contains (t , s , "Body\n " )
228+ // Metadata table with correct values.
229+ assert .Contains (t , s , "2026-03-18 16:00:00" )
230+ assert .Contains (t , s , "2026-03-18 17:00:00" )
231+ assert .Contains (t , s , "| iCloud |" )
232+ assert .Contains (t , s , "| Yes |" )
205233}
206234
207- func TestFSNoteWriter_WriteNote_FrontMatterContent (t * testing.T ) {
235+ func TestFSNoteWriter_WriteNote_MetadataSharedNo (t * testing.T ) {
208236 w , base := newTestWriter (t , "" , true )
209237
210- note := newTestNote ("Title With \" Quotes \" " , "Notes" , "Body \n " )
238+ note := newTestNote ("Test" , "Notes" , "Content \n " )
211239 relPath , err := w .WriteNote (context .Background (), & note )
212240 require .NoError (t , err )
213241
214242 content , err := os .ReadFile (filepath .Join (base , relPath ))
215243 require .NoError (t , err )
216244
217- s := string (content )
218- assert .True (t , strings .HasPrefix (s , "---\n " ))
219- assert .Contains (t , s , `title: "Title With \"Quotes\""` )
220- assert .Contains (t , s , "created: 2026-03-18T16:00:00Z" )
221- assert .Contains (t , s , "modified: 2026-03-18T17:00:00Z" )
222- assert .Contains (t , s , "shared: false" )
245+ assert .Contains (t , string (content ), "| No |" )
223246}
0 commit comments