Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns 1 and -1 for two unequal durations ("P1Y" and "P367D")', () => {
const duration1 = Duration.fromString('P1Y'),
duration2 = Duration.fromString('P367D');
chai.assert.equal(duration1.compare(duration2), -1);
chai.assert.equal(duration2.compare(duration1), 1);
});
it('returns undefined (indeterminate) for two durations ("P1M" and "P30D")', () => {
const duration1 = Duration.fromString('P1M'),
duration2 = Duration.fromString('P30D');
chai.assert.equal(duration1.compare(duration2), undefined);
chai.assert.equal(duration2.compare(duration1), undefined);
});
it('returns undefined (indeterminate) for two durations ("P1M" and "P31D")', () => {
it('returns 1 and -1 for two unequal durations ("P2D" and "P1D")', () => {
const duration1 = Duration.fromString('P2D'),
duration2 = Duration.fromString('P1D');
chai.assert.equal(duration1.compare(duration2), 1);
chai.assert.equal(duration2.compare(duration1), -1);
});
it('returns 1 and -1 for two unequal durations ("PT2H" and "PT1H")', () => {
it('returns 1 and -1 for two unequal durations ("P2Y" and "P1Y")', () => {
const duration1 = Duration.fromString('P2Y'),
duration2 = Duration.fromString('P1Y');
chai.assert.equal(duration1.compare(duration2), 1);
chai.assert.equal(duration2.compare(duration1), -1);
});
it('returns 1 and -1 for two unequal durations ("P2M" and "P1M")', () => {
it('returns 1 and -1 for two unequal durations ("-PT1S" and "-PT2S")', () => {
const duration1 = Duration.fromString('-PT1S'),
duration2 = Duration.fromString('-PT2S');
chai.assert.equal(duration1.compare(duration2), 1);
chai.assert.equal(duration2.compare(duration1), -1);
});
it('returns undefined (indeterminate) for two durations ("P1M" and "P31D")', () => {
const duration1 = Duration.fromString('P1M'),
duration2 = Duration.fromString('P31D');
chai.assert.equal(duration1.compare(duration2), undefined);
chai.assert.equal(duration2.compare(duration1), undefined);
});
it('returns 1 and -1 for two unequal durations ("P1M" and "P32D")', () => {
it('returns undefined (indeterminate) for two durations ("P1Y" and "P365D")', () => {
const duration1 = Duration.fromString('P1Y'),
duration2 = Duration.fromString('P365D');
chai.assert.equal(duration1.compare(duration2), undefined);
chai.assert.equal(duration2.compare(duration1), undefined);
});
it('returns undefined (indeterminate) for two durations ("P1Y" and "P366D")', () => {
it('returns 0 for two equal durations ("PT1S" and "PT1S")', () => {
const duration1 = Duration.fromString('PT1S'),
duration2 = Duration.fromString('PT1S');
chai.assert.equal(duration1.compare(duration2), 0);
chai.assert.equal(duration2.compare(duration1), 0);
});
it('returns 0 for two equal durations ("P1Y1M1DT1H1M1.1S" and "P1Y1M1DT1H1M1.1S")', () => {
it('returns 1 and -1 for two unequal durations ("-P1Y" and "-P2Y")', () => {
const duration1 = Duration.fromString('-P1Y'),
duration2 = Duration.fromString('-P2Y');
chai.assert.equal(duration1.compare(duration2), 1);
chai.assert.equal(duration2.compare(duration1), -1);
});
it('returns 1 and -1 for two unequal durations ("-P1M" and "-P2M")', () => {
() =>
castToType(
createAtomicValue(
Duration.fromString('P10Y10M10DT10H10M10S'),
'xs:duration'
),
'xs:gMonthDay'
),
'XPTY0004'