Repository: appsmithorg/appsmith
File: app/client/src/components/propertyControls/TableComputeValue.test.tsx (TypeScript)

Code before:
    expect(
      ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
    ).toBe(`{{${input}}}`);
  });

  it("2. should extract computation logic from array compute binding", () => {
    const input = `
    [
		{
			"value": "male",
			"label": "male"
		},
		{
			"value": "female",
			"label": "female"
		}
	]
    `;
    const computedValue = ComputeTablePropertyControlV2.getTableComputeBinding(
      tableName,
      input,
    );

    expect(
      ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
    ).toBe(`{{${input}}}`);
  });

  it("3. should handle numeric values", () => {
    const inputs = ["123", "-456", "0.123", "-0.456"];

    inputs.forEach((input) => {
      const computedValue =
        ComputeTablePropertyControlV2.getTableComputeBinding(tableName, input);

      expect(
        ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
      ).toBe(`{{${input}}}`);
    });
  });

  it("4. should handle boolean values", () => {
    const inputs = ["true", "false"];

    inputs.forEach((input) => {
      const computedValue =
        ComputeTablePropertyControlV2.getTableComputeBinding(tableName, input);

      expect(
        ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
      ).toBe(`{{${input}}}`);

Review comment (suggestion):
Input initialization and output verification repitition is unnecessary. 
What I mean is you can have something like:
```
const checks = ["currentRow.price",  `
    [
		{
			"value": "male",
			"label": "male"
		},
		{
			"value": "female",
			"label": "female"
		}
	]
    `, ["123", "-456", "0.123", "-0.456"], 
.... and so on
]

for(const input  of checks) {
	const computedValue = ComputeTablePropertyControlV2.getTableComputeBinding(
      tableName,
      input,
    );

expect(
      ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
    ).toBe(`{{${input}}}`);
}
```

this way you will have only one unit test with a lot of inputs.

Code after:
      {
        "value": "female",
        "label": "female"
      }
    ]
    `,
    `["123", "-456", "0.123", "-0.456"]`,
    `["true", "false"]`,
    `["null", "undefined"]`,
    `{
      "name": "John Doe",
      "age": 30,
      "isActive": true,
      "address": {
        "street": "123 Main St",
        "city": "Boston"
      },
      "hobbies": ["reading", "gaming"]
    }`,
    "() => { return true; }",
    "(x) => x * 2",
    "currentRow.price * 2",
    "currentRow.isValid && true",
    "!currentRow.isDeleted",
  ];

  it("1. should return the correct computed value", () => {
    inputVariations.forEach((input) => {
      const computedValue =
        ComputeTablePropertyControlV2.getTableComputeBinding(tableName, input);

      expect(
        ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
      ).toBe(`{{${input}}}`);
    });
  });

  it("2. should handle addition values", () => {
    const input = "currentRow.quantity + 5";
    const computedValue = ComputeTablePropertyControlV2.getTableComputeBinding(
      tableName,
      input,
    );

    expect(
      ComputeTablePropertyControlV2.getInputComputedValue(computedValue),
    ).toBe(`{{currentRow.quantity}}{{5}}`);
  });
});