-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c50f7df
commit 7748961
Showing
6 changed files
with
158 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,70 @@ | ||
import { describe, it, assertEqual, assertNotEqual, assertTrue, assertFalse, assertThrows, assertNoDuplicates, runTestFunction } from '../src/testRunner.js'; | ||
|
||
// First test suite | ||
await describe('I am an Example Test Suite', (description) => { | ||
await describe('I am an Example Test Suite', () => { | ||
|
||
it('should pass equality assertion', () => { | ||
assertEqual(1, 1, 'Expected 1 to equal 1'); | ||
}, description); | ||
assertEqual(1, 2, 'Expected 1 to equal 1'); | ||
}); | ||
|
||
it('should pass inequality assertion', () => { | ||
assertNotEqual(1, 2, 'Expected 1 not to equal 2'); | ||
}, description); | ||
}); | ||
|
||
it('should pass true assertion', () => { | ||
assertTrue(true, 'Expected true to be true'); | ||
}, description); | ||
}); | ||
|
||
it('should pass false assertion', () => { | ||
assertFalse(false, 'Expected false to be false'); | ||
}, description); | ||
}); | ||
|
||
it('should pass error assertion', () => { | ||
assertThrows(() => { | ||
throw new Error('An error occurred'); | ||
}, 'An error occurred', 'Expected an error to be thrown'); | ||
}, description); | ||
}); | ||
|
||
it('should deeply compare objects', () => { | ||
const obj1 = { a: 1, b: { c: 2 } }; | ||
const obj2 = { a: 1, b: { c: 2 } }; | ||
assertEqual(obj1, obj2, 'Expected objects to be deeply equal'); | ||
}, description); | ||
}); | ||
|
||
it('should check for duplicates', () => { | ||
const array = ['field1', 'field2'] | ||
assertNoDuplicates(array, 'There should be no duplicates'); | ||
}, description); | ||
}); | ||
|
||
}); | ||
|
||
|
||
await describe('I am the first describe', async () => { | ||
await runTestFunction(testFunction, { showSummary: false }, 'I am the first function'); | ||
await runTestFunction(testFunction, { showSummary: false }, 'I am the second function'); | ||
|
||
await describe('I am the second describe', async () => { | ||
|
||
it('should pass equality assertion', () => { | ||
assertEqual(1, 2, 'Expected 1 to equal 1'); | ||
}); | ||
|
||
it('should pass equality assertion', () => { | ||
assertEqual(1, 2, 'Expected 1 to equal 1'); | ||
}); | ||
|
||
await runTestFunction(testFunction, { showSummary: false }, 'I am the third function'); | ||
|
||
await describe('I am the third describe', async () => { | ||
|
||
await runTestFunction(testFunction, { showSummary: false }, 'I am the fouth function'); | ||
}) | ||
}) | ||
}); | ||
|
||
await runTestFunction(testFunction, { showSummary: false }); | ||
|
||
function testFunction() { | ||
it('First', () => { | ||
assertEqual(1, 1, 'Expected 1 to equal 1'); | ||
}, 'Function: testFunction'); | ||
}); | ||
} |