Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('from xs:dateTime', () =>
chai.assert.deepEqual(
castToType(
createAtomicValue(
DateTime.fromString('2000-10-10T10:10:10+10:30'),
'xs:dateTime'
),
'xs:gYear'
),
createAtomicValue(DateTime.fromString('2000+10:30'), 'xs:gYear')
));
it('from xs:time (throws XPTY0004)', () =>
it('from xs:dayTimeDuration', () =>
chai.assert.deepEqual(
castToType(
createAtomicValue(Duration.fromString('P10DT10H10M10S'), 'xs:dayTimeDuration'),
'xs:untypedAtomic'
),
createAtomicValue('P10DT10H10M10S', 'xs:untypedAtomic')
));
it('from xs:dateTime', () =>
it('from xs:string', () =>
chai.assert.deepEqual(
castToType(
createAtomicValue('2000-10-10T10:10:10+10:30', 'xs:string'),
'xs:dateTime'
),
createAtomicValue(DateTime.fromString('2000-10-10T10:10:10+10:30'), 'xs:dateTime')
));
it('from xs:float (throws XPTY0004)', () =>
it('from xs:untypedAtomic', () =>
chai.assert.deepEqual(
castToType(createAtomicValue('10.10', 'xs:untypedAtomic'), 'xs:double'),
createAtomicValue(10.1, 'xs:double')
));
it('from xs:string', () =>
it('from xs:untypedAtomic', () =>
chai.assert.deepEqual(
castToType(createAtomicValue('10:10:10+10:30', 'xs:untypedAtomic'), 'xs:time'),
createAtomicValue(DateTime.fromString('10:10:10+10:30'), 'xs:time')
));
it('from xs:string', () =>
it('from xs:float', () =>
chai.assert.deepEqual(
castToType(createAtomicValue(10.123, 'xs:float'), 'xs:string'),
createAtomicValue('10.123', 'xs:string')
));
it('from xs:double', () =>
() => castToType(createAtomicValue(10.123, 'xs:float'), 'xs:time'),
'XPTY0004'
() =>
castToType(
createAtomicValue(
DateTime.fromString('2000-10-10T10:10:10+10:30'),
'xs:dateTime'
),
'xs:double'
),
'XPTY0004'
() =>
castToType(
createAtomicValue(Duration.fromString('P10Y10M'), 'xs:dayTimeDuration'),
'xs:float'
),
'XPTY0004'
chai.assert.throw(() =>
castToType(createAtomicValue('string', 'xs:string'), 'xs:anySimpleType')
);