Adding more test cases.

This commit is contained in:
mike12345567 2025-01-20 11:16:19 +00:00
parent 272bbf5f8b
commit bd5e55480e
1 changed files with 27 additions and 7 deletions

View File

@ -21,13 +21,33 @@ describe("Javascript", () => {
console.log("foo");
return "hello"`
)
expect(output.result).toBe("hello")
expect(output.logs[0].log).toBe("hello")
expect(output.logs[0].line).toBe(1)
expect(output.logs[1].log).toBe("world")
expect(output.logs[1].line).toBe(2)
expect(output.logs[2].log).toBe("foo")
expect(output.logs[2].line).toBe(3)
expect(output.result).toEqual("hello")
expect(output.logs[0].log).toEqual(["hello"])
expect(output.logs[0].line).toEqual(1)
expect(output.logs[1].log).toEqual(["world"])
expect(output.logs[1].line).toEqual(2)
expect(output.logs[2].log).toEqual(["foo"])
expect(output.logs[2].line).toEqual(3)
})
})
it("should log comma separated values", () => {
const output = processJS(`console.log(1, { a: 1 }); return 1`)
expect(output.logs[0].log).toEqual([1, JSON.stringify({ a: 1 })])
expect(output.logs[0].line).toEqual(1)
})
it("should return the type working with warn", () => {
const output = processJS(`console.warn("warning"); return 1`)
expect(output.logs[0].log).toEqual(["warning"])
expect(output.logs[0].line).toEqual(1)
expect(output.logs[0].type).toEqual("warn")
})
it("should return the type working with error", () => {
const output = processJS(`console.error("error"); return 1`)
expect(output.logs[0].log).toEqual(["error"])
expect(output.logs[0].line).toEqual(1)
expect(output.logs[0].type).toEqual("error")
})
})