Adds Relative Time options now,weeks & years (#4304)
* Adds 'now' as an option in relative time * reenables no-console in previous spot * Adds weeks,months,years and abbreviations * modified tests to address coverage * month be gone!
This commit is contained in:
committed by
GitHub
parent
84aadba23a
commit
46af1b6955
@@ -387,9 +387,9 @@ describe('relativeTimeToDate', () => {
|
||||
|
||||
describe('In the future', () => {
|
||||
it('should parse valid natural time', () => {
|
||||
const text = 'in 12 days 10 hours 24 minutes 30 seconds';
|
||||
const text = 'in 1 year 2 weeks 12 days 10 hours 24 minutes 30 seconds';
|
||||
const { result, status, info } = transform.relativeTimeToDate(text, now);
|
||||
expect(result.toISOString()).toBe('2017-10-08T23:52:46.617Z');
|
||||
expect(result.toISOString()).toBe('2018-10-22T23:52:46.617Z');
|
||||
expect(status).toBe('success');
|
||||
expect(info).toBe('future');
|
||||
});
|
||||
@@ -405,6 +405,16 @@ describe('relativeTimeToDate', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('From now', () => {
|
||||
it('should equal current time', () => {
|
||||
const text = 'now';
|
||||
const { result, status, info } = transform.relativeTimeToDate(text, now);
|
||||
expect(result.toISOString()).toBe('2017-09-26T13:28:16.617Z');
|
||||
expect(status).toBe('success');
|
||||
expect(info).toBe('present');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Error cases', () => {
|
||||
it('should error if string is completely gibberish', () => {
|
||||
expect(transform.relativeTimeToDate('gibberishasdnklasdnjklasndkl123j123')).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user