forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBogoSort.test.js
More file actions
27 lines (22 loc) · 711 Bytes
/
BogoSort.test.js
File metadata and controls
27 lines (22 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { bogoSort, isSorted } from '../BogoSort'
describe('isSorted', () => {
it('should return true for empty arrays', () => {
expect(isSorted([])).toBe(true)
})
it('should return true for single-element arrays', () => {
expect(isSorted([1])).toBe(true)
})
it('should return true for arrays that are properly sorted', () => {
expect(isSorted([1, 2, 3])).toBe(true)
})
it('should return false for arrays that are not properly sorted', () => {
expect(isSorted([3, 2, 1])).toBe(false)
})
})
describe('bogoSort', () => {
it('should (eventually) sort the array', () => {
expect(bogoSort([5, 6, 7, 8, 1, 2, 12, 14])).toEqual([
1, 2, 5, 6, 7, 8, 12, 14
])
})
})