From c267a35fb025e84b30f51154ee37113ef9679a92 Mon Sep 17 00:00:00 2001 From: Tobias Lundin Date: Wed, 13 Apr 2022 21:30:03 +0200 Subject: [PATCH] Test code against @js-temporal/polyfill (#27) - remove type tests - add tests against temporal - correct comma use - check fractions - throw range errors for incorrect patterns - fix fractional hours and minutes - refactor tests - do not allow fractional Y/M/D - allow mixing weeks (W) with other designators - use correct temporal polyfill - fix week parsing like temporal - update readme and comments with format - update build badge - run tests on all push --- .github/workflows/pr-test.yml | 2 +- README.md | 14 +++---- lib/index.js | 46 ++++++++++++--------- package.json | 3 +- src/index.ts | 53 ++++++++++++++---------- test/iso8601-tests.ts | 76 +++++++++++++++++++++++++++++------ test/type-tests.ts | 9 ----- 7 files changed, 133 insertions(+), 70 deletions(-) delete mode 100644 test/type-tests.ts diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index d48833a..c44682d 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -1,5 +1,5 @@ name: Run Tests -on: [pull_request] +on: [push] jobs: Npm-Install-And-Test: runs-on: ubuntu-latest diff --git a/README.md b/README.md index c93ba36..79f6980 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,22 @@ Node/Js-module for parsing and making sense of ISO8601-durations -[![Build Status: Travis](https://img.shields.io/travis/tolu/ISO8601-duration/master.svg)][travis] +[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Ftolu%2Fiso8601-duration%2Fbadge&style=popout)][gh-action] [![npm version](https://img.shields.io/npm/v/iso8601-duration.svg)][npm] ![npm bundle size][bundlephobia] -> A new standard is on it's way, see [Temporal.Duration](https://tc39.es/proposal-temporal/docs/duration.html) +> A new standard is on it's way, see [Temporal.Duration](https://tc39.es/proposal-temporal/docs/duration.html) +> Tests (most) in this module now validate against [@js-temporal/polyfill](https://www.npmjs.com/package/@js-temporal/polyfill) ## The ISO8601 duration format -Durations in ISO8601 comes in two formats: +Durations in ISO8601 comes in this string format: -- **`PnYnMnDTnHnMnS`** - `PT