Group tests in a describe

This commit is contained in:
Charlie Moore
2021-10-05 17:23:36 -04:00
parent eaa8dc64a7
commit 6bba9da118

View File

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