add test for UC modeling

This got fixed in the refactor last commit, where we added the petAppearance field!
This commit is contained in:
Emi Matchu 2020-09-27 03:19:10 -07:00
parent e57af14625
commit 914a06f8c7

View file

@ -344,4 +344,54 @@ describe("Pet", () => {
); );
expect(rows[0].body_id).toEqual(0); expect(rows[0].body_id).toEqual(0);
}); });
it("models unconverted pets", async () => {
useTestDb();
// First, model an unconverted pet, and check its pose and layers.
const res = await query({
query: gql`
query {
petOnNeopetsDotCom(petName: "Marishka82") {
pose
petAppearance {
id
pose
layers {
id
}
}
}
}
`,
});
expect(res).toHaveNoErrors();
const modeledPet = res.data.petOnNeopetsDotCom;
expect(modeledPet.pose).toEqual("UNCONVERTED");
expect(modeledPet.petAppearance.pose).toEqual("UNCONVERTED");
expect(modeledPet.petAppearance.layers).toHaveLength(1);
// Then, request the corresponding appearance fresh from the db, and
// confirm we get the same back as when we modeled the pet.
const res2 = await query({
query: gql`
query {
petAppearance(speciesId: "31", colorId: "36", pose: UNCONVERTED) {
id
layers {
id
}
}
}
`,
});
expect(res2).toHaveNoErrors();
const petAppearance = res2.data.petAppearance;
expect(petAppearance.id).toEqual(modeledPet.petAppearance.id);
expect(petAppearance.layers.map((l) => l.id)).toEqual(
modeledPet.petAppearance.layers.map((l) => l.id)
);
});
}); });