refactor: Still trying to reorganize edit mode to be more robust
This commit is contained in:
parent
85faf502c4
commit
c5a5b26797
487 changed files with 94669 additions and 144 deletions
|
|
@ -65,7 +65,7 @@ class TestRunner {
|
|||
}
|
||||
|
||||
expect(actual) {
|
||||
return {
|
||||
const expectObj = {
|
||||
toBe: (expected) => {
|
||||
if (actual !== expected) {
|
||||
throw new Error(`Expected ${expected}, got ${actual}`);
|
||||
|
|
@ -85,8 +85,49 @@ class TestRunner {
|
|||
if (actual) {
|
||||
throw new Error(`Expected falsy value, got ${actual}`);
|
||||
}
|
||||
},
|
||||
toBeGreaterThan: (expected) => {
|
||||
if (actual <= expected) {
|
||||
throw new Error(`Expected ${actual} to be greater than ${expected}`);
|
||||
}
|
||||
},
|
||||
toBeGreaterThanOrEqual: (expected) => {
|
||||
if (actual < expected) {
|
||||
throw new Error(`Expected ${actual} to be greater than or equal to ${expected}`);
|
||||
}
|
||||
},
|
||||
toBeLessThan: (expected) => {
|
||||
if (actual >= expected) {
|
||||
throw new Error(`Expected ${actual} to be less than ${expected}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add 'not' property for negation
|
||||
expectObj.not = {
|
||||
toBe: (expected) => {
|
||||
if (actual === expected) {
|
||||
throw new Error(`Expected ${actual} not to be ${expected}`);
|
||||
}
|
||||
},
|
||||
toContain: (expected) => {
|
||||
if (actual.includes(expected)) {
|
||||
throw new Error(`Expected "${actual}" not to contain "${expected}"`);
|
||||
}
|
||||
},
|
||||
toBeTruthy: () => {
|
||||
if (actual) {
|
||||
throw new Error(`Expected falsy value, got ${actual}`);
|
||||
}
|
||||
},
|
||||
toBeFalsy: () => {
|
||||
if (!actual) {
|
||||
throw new Error(`Expected truthy value, got ${actual}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return expectObj;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue