mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-21 03:30:55 +08:00

* BubbleSort enacements for nearly sorted or sorted array and added test cases * BubbleSort enacements for nearly sorted or sorted array and added test cases * Bubble sort requested changes solved * standard js style issue fixed
21 lines
850 B
JavaScript
21 lines
850 B
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])
|
|
})
|
|
})
|
|
|
|
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])
|
|
})
|
|
})
|