Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
9
test/tomorrow/tomorrow.js
Normal file
9
test/tomorrow/tomorrow.js
Normal file
@ -0,0 +1,9 @@
|
||||
const tomorrow = (long = false) => {
|
||||
let t = new Date();
|
||||
t.setDate(t.getDate() + 1);
|
||||
const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||
t.getDate()
|
||||
).padStart(2, '0')}`;
|
||||
return !long ? ret : `${ret}T00:00:00`;
|
||||
};
|
||||
module.exports = tomorrow;
|
||||
14
test/tomorrow/tomorrow.test.js
Normal file
14
test/tomorrow/tomorrow.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
const expect = require('expect');
|
||||
const tomorrow = require('./tomorrow.js');
|
||||
|
||||
|
||||
test('tomorrow is a Function', () => {
|
||||
expect(tomorrow).toBeInstanceOf(Function);
|
||||
});
|
||||
const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1);
|
||||
const t2 = new Date(tomorrow());
|
||||
t.equal(t1.getFullYear(), t2.getFullYear(), 'Returns the correct year');
|
||||
t.equal(t1.getMonth(), t2.getMonth(), 'Returns the correct month');
|
||||
t.equal(t1.getDate(), t2.getDate(), 'Returns the correct date');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user