@@ -16,6 +16,7 @@ vi.mock('~/composables/useSettings', () => ({
1616describe ( 'DateTime' , ( ) => {
1717 const testDate = '2024-01-15T12:00:00.000Z'
1818 const testDateObject = new Date ( '2024-06-15T10:30:00.000Z' )
19+ const testYear = testDateObject . getUTCFullYear ( )
1920
2021 beforeEach ( ( ) => {
2122 mockRelativeDates . value = false
@@ -61,12 +62,12 @@ describe('DateTime', () => {
6162 } )
6263
6364 describe ( 'title attribute' , ( ) => {
64- it ( 'uses datetime string as title by default' , async ( ) => {
65+ it ( 'has title with formatted date by default' , async ( ) => {
6566 const component = await mountSuspended ( DateTime , {
6667 props : { datetime : testDate } ,
6768 } )
6869 const timeEl = component . find ( 'time' )
69- expect ( timeEl . attributes ( 'title' ) ) . toBe ( testDate )
70+ expect ( timeEl . attributes ( 'title' ) ) . toContain ( testYear )
7071 } )
7172
7273 it ( 'uses custom title when provided' , async ( ) => {
@@ -81,12 +82,12 @@ describe('DateTime', () => {
8182 expect ( timeEl . attributes ( 'title' ) ) . toBe ( customTitle )
8283 } )
8384
84- it ( 'converts Date object to ISO string for title' , async ( ) => {
85+ it ( 'converts Date object to formatted date in title' , async ( ) => {
8586 const component = await mountSuspended ( DateTime , {
8687 props : { datetime : testDateObject } ,
8788 } )
8889 const timeEl = component . find ( 'time' )
89- expect ( timeEl . attributes ( 'title' ) ) . toBe ( testDateObject . toISOString ( ) )
90+ expect ( timeEl . attributes ( 'title' ) ) . toContain ( testYear )
9091 } )
9192 } )
9293
@@ -119,14 +120,14 @@ describe('DateTime', () => {
119120 let component = await mountSuspended ( DateTime , {
120121 props : { datetime : testDate } ,
121122 } )
122- expect ( component . find ( 'time' ) . attributes ( 'title' ) ) . toBe ( testDate )
123+ expect ( component . find ( 'time' ) . attributes ( 'title' ) ) . toContain ( testYear )
123124
124125 // Test with relative dates on
125126 mockRelativeDates . value = true
126127 component = await mountSuspended ( DateTime , {
127128 props : { datetime : testDate } ,
128129 } )
129- expect ( component . find ( 'time' ) . attributes ( 'title' ) ) . toBe ( testDate )
130+ expect ( component . find ( 'time' ) . attributes ( 'title' ) ) . toContain ( testYear )
130131 } )
131132 } )
132133
0 commit comments