Skip to content

Commit 6f68fde

Browse files
committed
test(format_time): adjust tests for shorter date without year
1 parent 269bad0 commit 6f68fde

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tests/unit/util_spec.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ describe('util.format_time', function()
110110

111111
local yesterday = os.time() - 86400 -- 24 hours ago
112112
local last_week = os.time() - (7 * 86400) -- 7 days ago
113+
local last_month = os.time() - (30 * 86400) -- 30 days ago
113114
local next_year = make_timestamp(today.year + 1, 6, 15, 12, 0, 0)
114115

115116
describe('today timestamps', function()
@@ -140,16 +141,14 @@ describe('util.format_time', function()
140141
end)
141142

142143
describe('other day timestamps', function()
143-
it('formats yesterday with full date', function()
144+
it('formats yesterday with same month date', function()
144145
local result = util.format_time(yesterday)
145-
assert.matches('^%d%d? %a%a%a %d%d%d%d %d%d?:%d%d [AP]M$', result)
146-
assert.matches('%d%d%d%d', result)
146+
assert.matches('^%d%d? %a%a%a %d%d?:%d%d [AP]M$', result)
147147
end)
148148

149-
it('formats last week with full date', function()
149+
it('formats last week with same month date', function()
150150
local result = util.format_time(last_week)
151-
assert.matches('^%d%d? %a%a%a %d%d%d%d %d%d?:%d%d [AP]M$', result)
152-
assert.matches('%d%d%d%d', result)
151+
assert.matches('^%d%d? %a%a%a %d%d?:%d%d [AP]M$', result)
153152
end)
154153

155154
it('formats future date with full date', function()
@@ -178,7 +177,7 @@ describe('util.format_time', function()
178177
assert.is_string(result)
179178

180179
local is_time_only = result:match('^%d%d?:%d%d [AP]M$')
181-
local is_full_date = result:match('^%d%d? %a%a%a %d%d%d%d %d%d?:%d%d [AP]M$')
180+
local is_full_date = result:match('^%d%d? %a%a%a %d%d?:%d%d [AP]M$')
182181
assert.is_true(is_time_only ~= nil or is_full_date ~= nil)
183182
end)
184183

@@ -229,7 +228,7 @@ describe('util.format_time', function()
229228
assert.matches('^%d%d?:%d%d [AP]M$', early_result)
230229
else
231230
-- Actually tomorrow
232-
assert.matches('^%d%d? %a%a%a %d%d%d%d %d%d?:%d%d [AP]M$', early_result)
231+
assert.matches('^%d%d? %a%a%a %d%d?:%d%d [AP]M$', early_result)
233232
end
234233
end)
235234
end)

0 commit comments

Comments
 (0)