Group tests in a describe

This commit is contained in:
Charlie Moore
2021-10-05 17:25:22 -04:00
parent 932599d37b
commit 6bb075df92

View File

@ -1,16 +1,17 @@
import { cycleSort } from '../CycleSort'
it('should correctly sort an input list that is sorted backwards', () => {
describe('cycleSort function', () => {
it('should correctly sort an input list that is sorted backwards', () => {
const array = [5, 4, 3, 2, 1]
expect(cycleSort(array)).toEqual([1, 2, 3, 4, 5])
})
})
it('should correctly sort an input list that is unsorted', () => {
it('should correctly sort an input list that is unsorted', () => {
const array = [15, 24, 3, 2224, 1]
expect(cycleSort(array)).toEqual([1, 3, 15, 24, 2224])
})
})
describe('Variations of input array lengths', () => {
describe('Variations of input array lengths', () => {
it('should return an empty list with the input list is an empty list', () => {
expect(cycleSort([])).toEqual([])
})
@ -26,9 +27,9 @@ describe('Variations of input array lengths', () => {
it('should correctly sort an input list of an even length', () => {
expect(cycleSort([40, 42, 56, 45, 12, 3])).toEqual([3, 12, 40, 42, 45, 56])
})
})
})
describe('Variations of input array elements', () => {
describe('Variations of input array elements', () => {
it('should correctly sort an input list that contains only positive numbers', () => {
expect(cycleSort([50, 33, 11, 2])).toEqual([2, 11, 33, 50])
})
@ -64,4 +65,5 @@ describe('Variations of input array elements', () => {
it('should correctly sort an input list that contains duplicates', () => {
expect(cycleSort([4, 3, 4, 2, 1, 2])).toEqual([1, 2, 2, 3, 4, 4])
})
})
})