Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active October 22, 2018 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/80a0a34b20b2b60f62daaed45d54c466 to your computer and use it in GitHub Desktop.
Save productioncoder/80a0a34b20b2b60f62daaed45d54c466 to your computer and use it in GitHub Desktop.
ISO 8601 parsing tests
import {parseISO8601TimePattern} from '../date-format';
describe('date-format ISO8601', () => {
test('parse 4 seconds ISO8601 video duration string ', () => {
expect(parseISO8601TimePattern('PT4S')).toEqual({years: 0, months: 0, days: 0, hours: 0, minutes: 0, seconds: 4});
});
test('parse 13 seconds ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('PT13S')).toEqual({years: 0, months: 0, days: 0, hours: 0, minutes: 0, seconds: 13});
});
test('parse 01:00 min ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('PT1M')).toEqual({years: 0, months: 0, days: 0, hours: 0, minutes: 1, seconds: 0});
});
test('parse 1:31 min ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('PT1M31S')).toEqual({years: 0, months: 0, days: 0, hours: 0, minutes: 1, seconds: 31});
});
test('parse 10:10 min ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('PT10M10S')).toEqual({years: 0, months: 0, days: 0, hours: 0, minutes: 10, seconds: 10});
});
test('parse 03:06:15 hours ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('PT3H6M15S')).toEqual({years: 0, months: 0, days: 0, hours: 3, minutes: 6, seconds: 15});
});
test('parse 13:30:47 hours ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('PT13H30M47S')).toEqual({years: 0, months: 0, days: 0, hours: 13, minutes: 30, seconds: 47});
});
test('parse 13:30:47 hours ISO8601 video duration string', () => {
expect(parseISO8601TimePattern('P1DT25M5S')).toEqual({years: 0, months: 0, days: 1, hours: 0, minutes: 25, seconds: 5});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment