Jest Test
Sat Sep 24 2022 00:03:15 GMT+0000 (UTC)
Saved by
@zaccamp
#javascript
#handlebars
#jest
// __tests__/helpers.test.js
const { format_date, format_plural } = require('../utils/helpers');
test('format_date() returns a date string', () => {
const date = new Date('2020-03-20 16:12:03');
expect(format_date(date)).toBe('3/20/2020');
});
========================
// /utils/helpers.js
module.exports = {
format_date: (date) => {
return `${new Date(date).getMonth() + 1}/${new Date(date).getDate()}/${new Date(date).getFullYear()}`;
},
};
content_copyCOPY
Comments