mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibJS/Tests: Use hasOwnProperty() for duplicate test check
The current way of doing this would also traverse the prototype chain, and therefore yield false positive results for keys like "toString".
This commit is contained in:
parent
d9702ff561
commit
346560d7c8
2 changed files with 9 additions and 4 deletions
|
@ -53,8 +53,7 @@ describe("ability to work with generic non-array objects", () => {
|
|||
);
|
||||
});
|
||||
|
||||
// FIXME: test-js asserts when this is just called "toString" ಠ_ಠ
|
||||
test("toString (FIXME)", () => {
|
||||
test("toString", () => {
|
||||
expect(Array.prototype.toString.call({})).toBe("[object Object]");
|
||||
expect(Array.prototype.toString.call({ join: "foo" })).toBe("[object Object]");
|
||||
expect(Array.prototype.toString.call({ join: () => "foo" })).toBe("foo");
|
||||
|
|
|
@ -431,7 +431,7 @@ class ExpectationError extends Error {
|
|||
if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {};
|
||||
|
||||
const suite = __TestResults__[suiteMessage];
|
||||
if (suite[message]) {
|
||||
if (Object.prototype.hasOwnProperty.call(suite, message)) {
|
||||
suite[message] = {
|
||||
result: "fail",
|
||||
details: "Another test with the same message did already run",
|
||||
|
@ -459,7 +459,13 @@ class ExpectationError extends Error {
|
|||
if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {};
|
||||
|
||||
const suite = __TestResults__[suiteMessage];
|
||||
if (suite[message]) throw new Error("Duplicate test name: " + message);
|
||||
if (Object.prototype.hasOwnProperty.call(suite, message)) {
|
||||
suite[message] = {
|
||||
result: "fail",
|
||||
details: "Another test with the same message did already run",
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
suite[message] = {
|
||||
result: "skip",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue