diff --git a/src/index.test.ts b/src/index.test.ts index 5035ab9..5e21eb6 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -40,6 +40,10 @@ describe('ms(string)', () => { expect(ms('1y')).toBe(31557600000); }); + it('should convert mo to ms', () => { + expect(ms('1mo')).toBe(2629800000); + }); + it('should work with decimals', () => { expect(ms('1.5h')).toBe(5400000); }); @@ -116,6 +120,10 @@ describe('ms(long string)', () => { expect(ms('1 week')).toBe(604800000); }); + it('should convert months to ms', () => { + expect(ms('1 month')).toBe(2629800000); + }); + it('should convert years to ms', () => { expect(ms('1 year')).toBe(31557600000); }); @@ -329,6 +337,28 @@ describe('ms(number)', () => { }); }); +// zero + +describe('ms(zero)', () => { + it('should handle zero as a string', () => { + expect(ms('0')).toBe(0); + }); + + it('should handle zero with unit', () => { + expect(ms('0ms')).toBe(0); + expect(ms('0s')).toBe(0); + expect(ms('0h')).toBe(0); + }); + + it('should handle zero as a number', () => { + expect(ms(0)).toBe('0ms'); + }); + + it('should handle zero with long format', () => { + expect(ms(0, { long: true })).toBe('0 ms'); + }); +}); + // invalid inputs describe('ms(invalid inputs)', () => {