From 323d3dd0404e6419fa6683ece0cdfac1bde93208 Mon Sep 17 00:00:00 2001 From: barsdeveloper Date: Thu, 6 Apr 2023 17:25:35 +0200 Subject: [PATCH] Fix serialization methods names in test --- cypress/e2e/parsing.cy.js | 106 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/cypress/e2e/parsing.cy.js b/cypress/e2e/parsing.cy.js index d8f453b..be586cb 100644 --- a/cypress/e2e/parsing.cy.js +++ b/cypress/e2e/parsing.cy.js @@ -17,70 +17,70 @@ describe("Serializer", () => { context("Boolean", () => { let serializer = SerializerFactory.getSerializer(Boolean) - it("Parses true", () => expect(serializer.deserialize("true")).to.be.true) - it("Parses True", () => expect(serializer.deserialize("True")).to.be.true) - it("Parses false", () => expect(serializer.deserialize("false")).to.be.false) - it("Parses False", () => expect(serializer.deserialize("False")).to.be.false) + it("Parses true", () => expect(serializer.read("true")).to.be.true) + it("Parses True", () => expect(serializer.read("True")).to.be.true) + it("Parses false", () => expect(serializer.read("false")).to.be.false) + it("Parses False", () => expect(serializer.read("False")).to.be.false) }) context("Integer", () => { let serializer = SerializerFactory.getSerializer(IntegerEntity) - it("Parses 0", () => expect(serializer.deserialize("0")) + it("Parses 0", () => expect(serializer.read("0")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(0) ) - it("Parses +0", () => expect(serializer.deserialize("+0")) + it("Parses +0", () => expect(serializer.read("+0")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(0) ) - it("Parses -0", () => expect(serializer.deserialize("-0")) + it("Parses -0", () => expect(serializer.read("-0")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(0) ) - it("Parses 99", () => expect(serializer.deserialize("99")) + it("Parses 99", () => expect(serializer.read("99")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(99) ) - it("Parses -8685", () => expect(serializer.deserialize("-8685")) + it("Parses -8685", () => expect(serializer.read("-8685")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(-8685) ) - it("Parses +555", () => expect(serializer.deserialize("+555")) + it("Parses +555", () => expect(serializer.read("+555")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(555) ) - it("Parses 1000000000", () => expect(serializer.deserialize("1000000000")) + it("Parses 1000000000", () => expect(serializer.read("1000000000")) .to.be.instanceOf(IntegerEntity) .and.property("value").to.be.equal(1000000000) ) - it("Throws when not an integer", () => expect(() => serializer.deserialize("1.2").value).to.throw()) + it("Throws when not an integer", () => expect(() => serializer.read("1.2").value).to.throw()) }) context("Number", () => { let serializer = SerializerFactory.getSerializer(Number) - it("Parses 0", () => expect(serializer.deserialize("0")).to.be.approximately(0, 0.00001)) - it("Parses +0", () => expect(serializer.deserialize("+0")).to.be.approximately(0, 0.00001)) - it("Parses -0", () => expect(serializer.deserialize("-0")).to.be.approximately(0, 0.00001)) - it("Parses 5", () => expect(serializer.deserialize("5")).to.be.approximately(5, 0.00001)) - it("Parses 0.05", () => expect(serializer.deserialize("0.05")).to.be.approximately(0.05, 0.00001)) - it("Parses -999.666", () => expect(serializer.deserialize("-999.666")).to.be.approximately(-999.666, 0.001)) - it("Parses +45.4545", () => expect(serializer.deserialize("+45.4545")).to.be.approximately(45.4545, 0.001)) - it("Parses +1000000000", () => expect(serializer.deserialize("+1000000000")).to.be.approximately(1E9, 0.1)) - it("Throws when not numeric", () => expect(() => serializer.deserialize("alpha")).to.throw()) + it("Parses 0", () => expect(serializer.read("0")).to.be.approximately(0, 0.00001)) + it("Parses +0", () => expect(serializer.read("+0")).to.be.approximately(0, 0.00001)) + it("Parses -0", () => expect(serializer.read("-0")).to.be.approximately(0, 0.00001)) + it("Parses 5", () => expect(serializer.read("5")).to.be.approximately(5, 0.00001)) + it("Parses 0.05", () => expect(serializer.read("0.05")).to.be.approximately(0.05, 0.00001)) + it("Parses -999.666", () => expect(serializer.read("-999.666")).to.be.approximately(-999.666, 0.001)) + it("Parses +45.4545", () => expect(serializer.read("+45.4545")).to.be.approximately(45.4545, 0.001)) + it("Parses +1000000000", () => expect(serializer.read("+1000000000")).to.be.approximately(1E9, 0.1)) + it("Throws when not numeric", () => expect(() => serializer.read("alpha")).to.throw()) }) context("String", () => { let serializer = SerializerFactory.getSerializer(String) - it('Parses ""', () => expect(serializer.deserialize('""')).to.be.equal("")) - it('Parses "hello"', () => expect(serializer.deserialize('"hello"')).to.be.equal("hello")) + it('Parses ""', () => expect(serializer.read('""')).to.be.equal("")) + it('Parses "hello"', () => expect(serializer.read('"hello"')).to.be.equal("hello")) it('Parses "hello world 123 - éèàò@ç ^ ^^^"', () => - expect(serializer.deserialize('"hello world 123 - éèàò@ç ^ ^^^"')) + expect(serializer.read('"hello world 123 - éèàò@ç ^ ^^^"')) .to.be.equal("hello world 123 - éèàò@ç ^ ^^^") ) - it(String.raw`Parses "\""`, () => expect(serializer.deserialize(String.raw`"\""`)).to.be.equal('"')) + it(String.raw`Parses "\""`, () => expect(serializer.read(String.raw`"\""`)).to.be.equal('"')) }) context("KeyBindingEntity", () => { @@ -88,22 +88,22 @@ describe("Serializer", () => { it("Parses A", () => - expect(serializer.deserialize("A")) + expect(serializer.read("A")) .to.be.instanceOf(KeyBindingEntity) .and.to.deep.contain({ Key: { value: "A" } }) ) it("Parses (bCtrl=True,Key=A)", () => - expect(serializer.deserialize("(bCtrl=True,Key=A)")) + expect(serializer.read("(bCtrl=True,Key=A)")) .to.be.instanceOf(KeyBindingEntity) .and.to.deep.contain({ Key: { value: "A" }, bCtrl: true }) ) it("Parses (bCtrl=false,bShift=false,bCmd=false,bAlt=false,Key=X)", () => - expect(serializer.deserialize("(bCtrl=false,bShift=false,bCmd=true,bAlt=false,Key=X)")) + expect(serializer.read("(bCtrl=false,bShift=false,bCmd=true,bAlt=false,Key=X)")) .to.be.instanceOf(KeyBindingEntity) .and.to.deep.contain({ Key: { value: "X" }, bAlt: false, bCtrl: false, bCmd: true }) ) it("Parses spaces correctly", () => - expect(serializer.deserialize("( bCtrl= false \n, Key \n\n\n =Y ,bAlt=true )")) + expect(serializer.read("( bCtrl= false \n, Key \n\n\n =Y ,bAlt=true )")) .to.be.instanceOf(KeyBindingEntity) .and.to.deep.contain({ Key: { value: "Y" }, bAlt: true, bCtrl: false }) ) @@ -113,30 +113,30 @@ describe("Serializer", () => { let serializer = SerializerFactory.getSerializer(GuidEntity) it("Parses 0556a3ecabf648d0a5c07b2478e9dd32", () => - expect(serializer.deserialize("0556a3ecabf648d0a5c07b2478e9dd32")) + expect(serializer.read("0556a3ecabf648d0a5c07b2478e9dd32")) .to.be.instanceOf(GuidEntity) .and.property("value").to.be.equal("0556a3ecabf648d0a5c07b2478e9dd32") ) it("Parses 64023BC344E0453DBB583FAC411489BC", () => - expect(serializer.deserialize("64023BC344E0453DBB583FAC411489BC")) + expect(serializer.read("64023BC344E0453DBB583FAC411489BC")) .to.be.instanceOf(GuidEntity) .and.property("value").to.be.equal("64023BC344E0453DBB583FAC411489BC") ) it("Parses 6edC4a425ca948da8bC78bA52DED6C6C", () => - expect(serializer.deserialize("6edC4a425ca948da8bC78bA52DED6C6C")) + expect(serializer.read("6edC4a425ca948da8bC78bA52DED6C6C")) .to.be.instanceOf(GuidEntity) .and.property("value").to.be.equal("6edC4a425ca948da8bC78bA52DED6C6C") ) it("Throws when finding space", () => - expect(() => serializer.deserialize("172087193 9B04362973544B3564FDB2C")) + expect(() => serializer.read("172087193 9B04362973544B3564FDB2C")) .to.throw() ) it("Throws when shorter by 1", () => - expect(() => serializer.deserialize("E25F14F8F3E9441AB07153E7DA2BA2B")) + expect(() => serializer.read("E25F14F8F3E9441AB07153E7DA2BA2B")) .to.throw() ) it("Throws when longer by 1", () => - expect(() => serializer.deserialize("A78988B0097E48418C8CB87EC5A67ABF7")) + expect(() => serializer.read("A78988B0097E48418C8CB87EC5A67ABF7")) .to.throw() ) }) @@ -144,21 +144,21 @@ describe("Serializer", () => { context("Vector", () => { let serializer = SerializerFactory.getSerializer(VectorEntity) - it("Parses simple vector", () => expect(serializer.deserialize("(X=1,Y=2,Z=3.5)")) + it("Parses simple vector", () => expect(serializer.read("(X=1,Y=2,Z=3.5)")) .to.be.deep.equal({ X: 1, Y: 2, Z: 3.5, }) ) - it("Parses trailing comma", () => expect(serializer.deserialize("(X=10,Y=+20.88,Z=-30.54,)")) + it("Parses trailing comma", () => expect(serializer.read("(X=10,Y=+20.88,Z=-30.54,)")) .to.be.deep.equal({ X: 10, Y: 20.88, Z: -30.54, }) ) - it("Parses weird spaces", () => expect(serializer.deserialize(`( + it("Parses weird spaces", () => expect(serializer.read(`( Z = -3.66 , X @@ -174,13 +174,13 @@ describe("Serializer", () => { Z: -3.66, }) ) - it("Throws when unexpected types", () => expect(() => serializer.deserialize("(X=1,Y=\"2\",Z=3)")) + it("Throws when unexpected types", () => expect(() => serializer.read("(X=1,Y=\"2\",Z=3)")) .to.throw() ) - it("Throws when missing a key", () => expect(() => serializer.deserialize("(X=1,Z=3)")) + it("Throws when missing a key", () => expect(() => serializer.read("(X=1,Z=3)")) .to.throw() ) - it("Throws when finding unexpected keys", () => expect(() => serializer.deserialize("(X=1,Y=2,Unexpected=6,Z=3.5)")) + it("Throws when finding unexpected keys", () => expect(() => serializer.read("(X=1,Y=2,Unexpected=6,Z=3.5)")) .to.throw() ) }) @@ -188,19 +188,19 @@ describe("Serializer", () => { context("Vector2D", () => { let serializer = SerializerFactory.getSerializer(Vector2DEntity) - it("Parses simple vector", () => expect(serializer.deserialize("(X=78,Y=56.3)")) + it("Parses simple vector", () => expect(serializer.read("(X=78,Y=56.3)")) .to.be.deep.equal({ X: 78, Y: 56.3, }) ) - it("Parses trailing comma", () => expect(serializer.deserialize("(X=+4.5,Y=-8.88,)")) + it("Parses trailing comma", () => expect(serializer.read("(X=+4.5,Y=-8.88,)")) .to.be.deep.equal({ X: 4.5, Y: -8.88, }) ) - it("Parses weird spaces", () => expect(serializer.deserialize(`( + it("Parses weird spaces", () => expect(serializer.read(`( Y = +93.004 , X @@ -211,13 +211,13 @@ describe("Serializer", () => { Y: 93.004, }) ) - it("Throws on unexpected type", () => expect(() => serializer.deserialize("(X=1,Y=\"2\")")) + it("Throws on unexpected type", () => expect(() => serializer.read("(X=1,Y=\"2\")")) .to.throw() ) - it("Throws when missing a key", () => expect(() => serializer.deserialize("(X=1)")) + it("Throws when missing a key", () => expect(() => serializer.read("(X=1)")) .to.throw() ) - it("Throws when finding unexpected keys", () => expect(() => serializer.deserialize("(X=777, Y=555, Unexpected=6, HH=2)")) + it("Throws when finding unexpected keys", () => expect(() => serializer.read("(X=777, Y=555, Unexpected=6, HH=2)")) .to.throw() ) }) @@ -233,28 +233,28 @@ describe("Serializer", () => { expect(result.toHSVA()).to.be.deep.equal([0, 0, 1, 1]) }) it("Parses red color", () => { - const result = serializer.deserialize("(R=1,G=0,B=0)") + const result = serializer.read("(R=1,G=0,B=0)") expect(result.toRGBA()).to.be.deep.equal([255, 0, 0, 255]) expect(result.toRGBAString()).to.be.equal("FF0000FF") expect(result.toNumber()).to.be.equal(-16776961) expect(result.toHSVA()).to.be.deep.equal([0, 1, 1, 1]) }) it("Parses simple color", () => { - const result = serializer.deserialize("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)") + const result = serializer.read("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)") expect(result.toRGBA()).to.be.deep.equal([0, 168, 255, 255]) expect(result.toRGBAString()).to.be.equal("00A8FFFF") expect(result.toNumber()).to.be.equal(11075583) expect(result.toHSVA()).to.be.deep.equal([0.55666666666666666666, 1, 1, 1]) }) it("Parses wrong order keys", () => { - const result = serializer.deserialize("(B=0.04394509003266556,G=0.026789300067696642,A=0.83663232408635,R=0.6884158028074934,)") + const result = serializer.read("(B=0.04394509003266556,G=0.026789300067696642,A=0.83663232408635,R=0.6884158028074934,)") expect(result.toRGBA()).to.be.deep.equal([176, 7, 11, 213]) expect(result.toRGBAString()).to.be.equal("B0070BD5") expect(result.toNumber()).to.be.equal(-1341715499) expect(result.toHSVA().map(v => Utility.roundDecimals(v, 3))).to.be.deep.equal([0.996, 0.961, 0.688, 0.837]) }) it("Parses weird spaces", () => { - const result = serializer.deserialize(`( + const result = serializer.read(`( A = 0.327 , R=0.530 , G = 0.685 ,B @@ -264,10 +264,10 @@ describe("Serializer", () => { expect(result.toNumber()).to.be.equal(-2018515373) expect(result.toHSVA().map(v => Utility.roundDecimals(v, 3))).to.be.deep.equal([0.597, 0.411, 0.9, 0.327]) }) - it("Throws when missing an expected key", () => expect(() => serializer.deserialize("(R=0.000000,G=0.660000,A=1.000000)")) + it("Throws when missing an expected key", () => expect(() => serializer.read("(R=0.000000,G=0.660000,A=1.000000)")) .to.throw() ) - it("Throws when unexpected types", () => expect(() => serializer.deserialize("(R=0.000000,G=\"hello\",A=1.000000)")) + it("Throws when unexpected types", () => expect(() => serializer.read("(R=0.000000,G=\"hello\",A=1.000000)")) .to.throw() ) })