From b768a22b1cc95de5d4d76f9d2425c5faf3a3de7f Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Sun, 14 May 2017 16:11:17 +0200 Subject: [PATCH] Fix #689 - add unit test for v1 deserializer --- .../serialization/Deserializer_v1Test.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/js/utils/serialization/Deserializer_v1Test.js diff --git a/test/js/utils/serialization/Deserializer_v1Test.js b/test/js/utils/serialization/Deserializer_v1Test.js new file mode 100644 index 00000000..60576a89 --- /dev/null +++ b/test/js/utils/serialization/Deserializer_v1Test.js @@ -0,0 +1,28 @@ +describe("Deserializer v1 test", function() { + var B = '#000000'; + var T = Constants.TRANSPARENT_COLOR; + var data = { + "modelVersion": 1, + "piskel": { + "height": 2, + "width": 2, + "layers": [ + "{\"name\":\"Layer 1\",\"frames\":[\"[[\\\"#000000\\\",\\\"TRANSPARENT\\\"],[\\\"TRANSPARENT\\\",\\\"#000000\\\"]]\"]}" + ] + } + }; + + it("deserializes data serialized for model v0 correctly", function (done) { + var deserializer = pskl.utils.serialization.Deserializer; + deserializer.deserialize(data, function (p) { + // Check the frame has been properly deserialized + expect(p.getLayerAt(0).getFrames().length).toBe(1); + var frame = p.getLayerAt(0).getFrameAt(0); + test.testutils.frameEqualsGrid(frame, [ + [B, T], + [T, B] + ]); + done(); + }); + }); +});