diff --git a/test/statenormalisation-tests.js b/test/statenormalisation-tests.js index 9b2f7c9f5..cdc15fb03 100644 --- a/test/statenormalisation-tests.js +++ b/test/statenormalisation-tests.js @@ -77,3 +77,36 @@ describe("Normalizing clientstate", () => { normalizer.normalized.should.deep.equal(resultdata); }); }); + +describe("ClientState parsing", () => { + it("Should work without executors", () => { + const state = new clientstate.State({ + "sessions": [ + {"id":1, + "language":"c++", + "source":"int main() {}", + "compilers":[{"id":"g91","options":"-O3 -std=c++2a"}] + }] + }); + + state.sessions[0].compilers.length.should.equal(1); + state.sessions[0].executors.length.should.equal(0); + }); + + it("Should work with executor", () => { + const state = new clientstate.State({ + "sessions": [ + {"id":1, + "language":"c++", + "source":"int main() {}", + "compilers": [], + "executors":[{ + "compiler":{"id":"g91","options":"-O3 -std=c++2a"} + }] + }] + }); + + state.sessions[0].compilers.length.should.equal(0); + state.sessions[0].executors.length.should.equal(1); + }); +});