text: const syntax = require("../syntaxGraph.js");
  
  describe("IF syntax", () => {
    const mockCheckboxVarNames = ["is urgent", "i am a member"];
    const mockNumericVarNames = ["km", "meters"];
    describe("Validity", () => {
      describe("positive cases", () => {
        test("it correctly validates the first part (if part)", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(ifGRAPH.validateString("If is urgent is checked,").isValid).toBe(
            true
          );
          expect(
            ifGRAPH.validateString("If is urgent is not checked,").isValid
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If i am a member is checked,").isValid
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If i am a member is not checked,").isValid
          ).toBe(true);
        });
  
        test("it correctly validates the first + second part (operations)", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(
            ifGRAPH.validateString("If is urgent is checked, add 25").isValid
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If is urgent is not checked, subtract 10% from the km"
            ).isValid
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If i am a member is checked, multiply meters by 43,65"
            ).isValid
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If i am a member is checked, multiply the meters by the km"
            ).isValid
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If i am a member is not checked, divide it by the meters"
            ).isValid
          ).toBe(true);
        });
      });
  
      describe("negative cases", () => {
        test("it correctly invalidates wrong first parts (if part)", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(ifGRAPH.validateString("If a").isValid).toBe(false);
          expect(ifGRAPH.validateString("If the").isValid).toBe(false);
          expect(ifGRAPH.validateString("If km is").isValid).toBe(false);
          expect(ifGRAPH.validateString("If is urgent is a").isValid).toBe(false);
          expect(ifGRAPH.validateString("If is urgent is not a").isValid).toBe(
            false
          );
        });
      });
    });
  
    describe("Completeness", () => {
      describe("positive cases", () => {
        test("it correctly checks completeness of multiple combinations of checked/not checked with different operations", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(
            ifGRAPH.validateString("If i am a member is checked, add 1 to it")
              .isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If i am a member is checked, subtract 10%")
              .isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If i am a member is checked, multiply it by the meters"
            ).isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If i am a member is checked, divide it by the meters"
            ).isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If i am a member is checked, divide the km by the meters"
            ).isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If is urgent is not checked, add 1 to km")
              .isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If is urgent is not checked, subtract the meters from 134"
            ).isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If is urgent is not checked, multiply the meters by the meters"
            ).isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If is urgent is not checked, divide it by the meters"
            ).isComplete
          ).toBe(true);
          expect(
            ifGRAPH.validateString(
              "If is urgent is not checked, divide the km by the meters"
            ).isComplete
          ).toBe(true);
        });
      });
  
      describe("negative cases", () => {
        test("it correctly checks uncompleteness of sentences without the operation part", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(ifGRAPH.validateString("If").isComplete).toBe(false);
          expect(ifGRAPH.validateString("If is urgent is not ").isComplete).toBe(
            false
          );
          expect(
            ifGRAPH.validateString("If i am a member is chec").isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If i am a member is not checked, ").isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If is urgent is checked, ").isComplete
          ).toBe(false);
        });
  
        test("it correctly checks uncompleteness of sentences with an incomplete operation", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(
            ifGRAPH.validateString("If is urgent is not checked, add").isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If i am a member is not checked, subtract ")
              .isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If i am a member is not checked, divide ")
              .isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If i am a member is not checked, mult ")
              .isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If i am a member is not checked, add ")
              .isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If i am a member is not checked, add 1,")
              .isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString(
              "If is urgent is not checked, subtract the km from"
            ).isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString("If is urgent is not checked, multiply the km")
              .isComplete
          ).toBe(false);
          expect(
            ifGRAPH.validateString(
              "If i am a member is not checked, divide the km by the"
            ).isComplete
          ).toBe(false);
        });
      });
    });
  
    describe("Autocompletion", () => {
      describe("positive cases", () => {
        test("it correctly suggests the continuation of the first part of the sentence (if part)", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(
            ifGRAPH.validateString("If").suggestions.includes(" is urgent")
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If").suggestions.includes(" i am a member")
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If ").suggestions.includes("is urgent")
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If ").suggestions.includes("i am a member")
          ).toBe(true);
          expect(
            ifGRAPH.validateString("If is urgent ").suggestions.includes("is")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is")
              .suggestions.includes(" not checked")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is ")
              .suggestions.includes("checked")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is no")
              .suggestions.includes("t checked")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is chec")
              .suggestions.includes("ked")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is checked")
              .suggestions.includes(",")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked")
              .suggestions.includes(",")
          ).toBe(true);
        });
  
        test("it correctly suggests all the operations", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked,")
              .suggestions.includes(" Add")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked,")
              .suggestions.includes(" Subtract")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, ")
              .suggestions.includes("Multiply")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, ")
              .suggestions.includes("Divide")
          ).toBe(true);
        });
  
        test("it correctly suggests the continuation of the operations", () => {
          const ifGRAPH = new syntax.IfGraph(
            mockCheckboxVarNames,
            mockNumericVarNames
          );
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, a")
              .suggestions.includes("dd")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, subtra")
              .suggestions.includes("ct")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, multiply ")
              .suggestions.includes("1")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, multiply ")
              .suggestions.includes("the")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, multiply ")
              .suggestions.includes("km")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, multiply ")
              .suggestions.includes("meters")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, divide the")
              .suggestions.includes(" km")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, divide the")
              .suggestions.includes(" meters")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, divide the k")
              .suggestions.includes("m")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, divide the km ")
              .suggestions.includes("by")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, subtract 1")
              .suggestions.includes("1")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, subtract 14")
              .suggestions.includes(",")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, subtract 7")
              .suggestions.includes("%")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, divide the km by")
              .suggestions.includes(" the")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, multiply ")
              .suggestions.includes("it")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, add 23 to t")
              .suggestions.includes("he")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If i am a member is not checked, add 1,3% t")
              .suggestions.includes("o")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString("If is urgent is not checked, subtract the km from")
              .suggestions.includes(" meters")
          ).toBe(true);
          expect(
            ifGRAPH
              .validateString(
                "If is urgent is not checked, multiply the km by the me"
              )
              .suggestions.includes("ters")
          ).toBe(true);
        });
      });
      // No negative cases (wouldn't make sense)
    });
  
    describe("Parser", () => {
      test("it correctly parses sentences with different operations", () => {
        const ifGraph = new syntax.IfGraph(
          mockCheckboxVarNames,
          mockNumericVarNames
        );
        let [code] = ifGraph.parser("If is urgent is checked, add 1 to it");
        expect(code).toBe(
          "if (QQ_is_urgent) { currentValue = currentValue;currentValue += 1; }"
        );
        [code] = ifGraph.parser("If i am a member is not checked, Add 10 to km");
        expect(code).toBe(
          "if (!QQ_i_am_a_member) { currentValue = QQ_km;currentValue += 10; }"
        );
        [code] = ifGraph.parser("If i am a member is checked, subtract 12");
        expect(code).toBe(
          "if (QQ_i_am_a_member) { currentValue = currentValue;currentValue -= 12; }"
        );
        [code] = ifGraph.parser(
          "If is urgent is not checked, subtract the meters from 12"
        );
        expect(code).toBe(
          "if (!QQ_is_urgent) { currentValue = 12;currentValue -= QQ_meters; }"
        );
        [code] = ifGraph.parser("If is urgent is not checked, divide it by 5");
        expect(code).toBe(
          "if (!QQ_is_urgent) { currentValue = currentValue;currentValue /= 5; }"
        );
        [code] = ifGraph.parser(
          "If i am a member is checked, multiply the km by the meters"
        );
        expect(code).toBe(
          "if (QQ_i_am_a_member) { currentValue = QQ_km;currentValue *= QQ_meters; }"
        );
      });
    });
  });
  