mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00

* 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>
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import { alternativeBubbleSort, bubbleSort } from '../BubbleSort'
|
|
|
|
describe('bubbleSort', () => {
|
|
it('should sort arrays correctly', () => {
|
|
expect(bubbleSort([5, 4, 1, 2, 3])).toEqual([1, 2, 3, 4, 5])
|
|
expect(bubbleSort([])).toEqual([])
|
|
expect(bubbleSort([1, 2, 3])).toEqual([1, 2, 3])
|
|
expect(bubbleSort([5, 6, 7, 8, 1, 2, 12, 14])).toEqual([
|
|
1, 2, 5, 6, 7, 8, 12, 14
|
|
])
|
|
expect(bubbleSort([5, 6, 7, 8, 9, 4])).toEqual([4, 5, 6, 7, 8, 9])
|
|
expect(bubbleSort([20, 30, 40])).toEqual([20, 30, 40])
|
|
expect(bubbleSort([2, 1, 3])).toEqual([1, 2, 3])
|
|
expect(bubbleSort([10, 15, 16, 100])).toEqual([10, 15, 16, 100])
|
|
expect(bubbleSort([10, 9, 11])).toEqual([9, 10, 11])
|
|
expect(bubbleSort([10, 9, 12])).toEqual([9, 10, 12])
|
|
expect(bubbleSort([3, 2, 1])).toEqual([1, 2, 3])
|
|
expect(bubbleSort([10, 9, 8])).toEqual([8, 9, 10])
|
|
})
|
|
})
|
|
|
|
describe('alternativeBubbleSort', () => {
|
|
it('should sort arrays correctly', () => {
|
|
expect(alternativeBubbleSort([5, 4, 1, 2, 3])).toEqual([1, 2, 3, 4, 5])
|
|
expect(alternativeBubbleSort([])).toEqual([])
|
|
expect(alternativeBubbleSort([1, 2, 3])).toEqual([1, 2, 3])
|
|
expect(alternativeBubbleSort([5, 6, 7, 8, 1, 2, 12, 14])).toEqual([
|
|
1, 2, 5, 6, 7, 8, 12, 14
|
|
])
|
|
})
|
|
})
|