mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Added setExpirationDate implementation along with tests
This commit is contained in:
@@ -126,5 +126,42 @@ describe("PKPass", () => {
|
||||
|
||||
expect(pass.props["nfc"]).toBeUndefined();
|
||||
});
|
||||
|
||||
describe("setExpirationDate", () => {
|
||||
it("Won't apply changes without a valid argument", () => {
|
||||
const pass = new PKPass({}, {});
|
||||
|
||||
// @ts-expect-error
|
||||
pass.setExpirationDate();
|
||||
expect(pass.props["expirationDate"]).toBe(undefined);
|
||||
|
||||
// @ts-expect-error
|
||||
pass.setExpirationDate(42);
|
||||
expect(pass.props["expirationDate"]).toBe(undefined);
|
||||
});
|
||||
|
||||
it("expects a Date object as the only argument", () => {
|
||||
const pass = new PKPass({}, {});
|
||||
|
||||
pass.setExpirationDate(new Date(2020, 6, 1, 0, 0, 0, 0));
|
||||
// Month starts from 0 in Date Object when used this way, therefore
|
||||
// we expect one month more
|
||||
expect(pass.props["expirationDate"]).toBe(
|
||||
"2020-07-01T00:00:00Z",
|
||||
);
|
||||
});
|
||||
|
||||
it("An invalid date, will not apply changes", () => {
|
||||
const pass = new PKPass({}, {});
|
||||
|
||||
// @ts-expect-error
|
||||
pass.setExpirationDate("32/18/228317");
|
||||
expect(pass.props["expirationDate"]).toBe(undefined);
|
||||
|
||||
// @ts-expect-error
|
||||
pass.setExpirationDate("32/18/228317");
|
||||
expect(pass.props["expirationDate"]).toBe(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user