mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
feat: Test running overhaul, switch to Prettier & reformat everything (#1407)
* chore: Switch to Node 20 + Vitest * chore: migrate to vitest mock functions * chore: code style (switch to prettier) * test: re-enable long-running test Seems the switch to Node 20 and Vitest has vastly improved the code's and / or the test's runtime! see #1193 * chore: code style * chore: fix failing tests * Updated Documentation in README.md * Update contribution guidelines to state usage of Prettier * fix: set prettier printWidth back to 80 * chore: apply updated code style automatically * fix: set prettier line endings to lf again * chore: apply updated code style automatically --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
@ -16,16 +16,19 @@ describe('FindMinIterator', () => {
|
||||
expect(FindMinIterator([-1, 10])).toBe(-1)
|
||||
expect(FindMinIterator([0, 100])).toBe(0)
|
||||
expect(FindMinIterator([100, 0])).toBe(0)
|
||||
expect(FindMinIterator([100, 50, 20, 0, -100, 0, 2, 30, 45, 99, 104, 23])).toBe(-100)
|
||||
expect(
|
||||
FindMinIterator([100, 50, 20, 0, -100, 0, 2, 30, 45, 99, 104, 23])
|
||||
).toBe(-100)
|
||||
})
|
||||
|
||||
test('given empty generator then min is undefined', () => {
|
||||
const src = function* () { } // eslint-disable-line
|
||||
const src = function* () {} // eslint-disable-line
|
||||
expect(FindMinIterator(src())).toBeUndefined()
|
||||
})
|
||||
|
||||
test('given generator then min is found', () => {
|
||||
const src = function* () { // eslint-disable-line
|
||||
const src = function* () {
|
||||
// eslint-disable-line
|
||||
yield 1
|
||||
yield -1
|
||||
yield 0
|
||||
@ -34,12 +37,13 @@ describe('FindMinIterator', () => {
|
||||
})
|
||||
|
||||
test('given string generator then min string length is found', () => {
|
||||
const src = function* () { // eslint-disable-line
|
||||
const src = function* () {
|
||||
// eslint-disable-line
|
||||
yield 'abc'
|
||||
yield 'de'
|
||||
yield 'qwerty'
|
||||
}
|
||||
expect(FindMinIterator(src(), _x => _x.length)).toBe(2)
|
||||
expect(FindMinIterator(src(), (_x) => _x.length)).toBe(2)
|
||||
})
|
||||
|
||||
test('given array of objects then min accessor is found', () => {
|
||||
@ -48,7 +52,7 @@ describe('FindMinIterator', () => {
|
||||
{ name: 'Item #2', price: 0.0 },
|
||||
{ name: 'Item #3', price: -1.0 }
|
||||
]
|
||||
expect(FindMinIterator(array, _x => _x.price)).toBe(-1)
|
||||
expect(FindMinIterator(array, _x => _x.name)).toBe('Item #1')
|
||||
expect(FindMinIterator(array, (_x) => _x.price)).toBe(-1)
|
||||
expect(FindMinIterator(array, (_x) => _x.name)).toBe('Item #1')
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user