mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Added implementation of setLocations along with tests
This commit is contained in:
@@ -45,4 +45,54 @@ describe("PKPass", () => {
|
||||
expect(pass.props["beacons"].length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setLocations", () => {
|
||||
it("should reset instance.props['locations'] if 'null' is passed as value", () => {
|
||||
const pass = new PKPass({}, {});
|
||||
|
||||
pass.setLocations({
|
||||
longitude: 0.25456342344,
|
||||
latitude: 0.26665773234,
|
||||
});
|
||||
|
||||
expect(pass.props["locations"].length).toBe(1);
|
||||
|
||||
pass.setLocations(null);
|
||||
|
||||
expect(pass.props["locations"]).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should filter out invalid beacons objects", () => {
|
||||
const pass = new PKPass({}, {});
|
||||
|
||||
pass.setLocations(
|
||||
{
|
||||
// @ts-expect-error
|
||||
longitude: "unknown",
|
||||
// @ts-expect-error
|
||||
latitude: "unknown",
|
||||
},
|
||||
{
|
||||
altitude: "say hello from here",
|
||||
longitude: 0.25456342344,
|
||||
},
|
||||
{
|
||||
longitude: 0.25456342344,
|
||||
latitude: 0.26665773234,
|
||||
altitude: 12552.31233321,
|
||||
relevantText:
|
||||
/** Hi mom, see how do I fly! */
|
||||
"Ciao mamma, guarda come volooo!",
|
||||
},
|
||||
);
|
||||
|
||||
expect(pass.props["locations"].length).toBe(1);
|
||||
expect(pass.props["locations"][0].longitude).toBe(0.25456342344);
|
||||
expect(pass.props["locations"][0].latitude).toBe(0.26665773234);
|
||||
expect(pass.props["locations"][0].altitude).toBe(12552.31233321);
|
||||
expect(pass.props["locations"][0].relevantText).toBe(
|
||||
"Ciao mamma, guarda come volooo!",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user