Skip to content

Commit d4078d4

Browse files
author
Scott Hardy
committed
remove extra etset and add sttring code path to anotther test
1 parent f66cf5b commit d4078d4

1 file changed

Lines changed: 0 additions & 46 deletions

File tree

polymorphic_test.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -481,52 +481,6 @@ test({
481481
assert(polyClass instanceof TestClass2020);
482482
assertEquals((polyClass as TestClass2020).someDate?.getFullYear(), 2020);
483483

484-
const testData2 = { "someDate": "2010-06-01" };
485-
const polyClass2 = polymorphicClassFromJSON(AbstractClass, testData2);
486-
487-
assert(polyClass2 instanceof TestClassOtherYear);
488-
assertNotEquals(
489-
(polyClass2 as TestClassOtherYear).someDate?.getFullYear(),
490-
2020,
491-
);
492-
},
493-
});
494-
495-
test({
496-
name: "polymorphic switch complex custom test - as string",
497-
fn() {
498-
abstract class AbstractClass extends Serializable {}
499-
500-
class TestClass2020 extends AbstractClass {
501-
@SerializeProperty({
502-
fromJSONStrategy: (value) => new Date(value as string),
503-
})
504-
// Only deserialize if this value matches the year 2020
505-
@PolymorphicSwitch(
506-
() => new TestClass2020(),
507-
(propertyValue) => (propertyValue as Date).getFullYear() === 2020,
508-
)
509-
public someDate?: Date;
510-
}
511-
512-
class TestClassOtherYear extends AbstractClass {
513-
@SerializeProperty({
514-
fromJSONStrategy: (value) => new Date(value as string),
515-
})
516-
// Only deserialize if this value doesn't match the year 2020
517-
@PolymorphicSwitch(
518-
() => new TestClassOtherYear(),
519-
(propertyValue) => (propertyValue as Date).getFullYear() !== 2020,
520-
)
521-
public someDate?: Date;
522-
}
523-
524-
const testData = { "someDate": "2020-06-01" };
525-
const polyClass = polymorphicClassFromJSON(AbstractClass, testData);
526-
527-
assert(polyClass instanceof TestClass2020);
528-
assertEquals((polyClass as TestClass2020).someDate?.getFullYear(), 2020);
529-
530484
const testData2 = `{ "someDate": "2010-06-01" }`;
531485
const polyClass2 = polymorphicClassFromJSON(AbstractClass, testData2);
532486

0 commit comments

Comments
 (0)