mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
Group tests in a describe
This commit is contained in:
@ -1,16 +1,17 @@
|
|||||||
import { cycleSort } from '../CycleSort'
|
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]
|
const array = [5, 4, 3, 2, 1]
|
||||||
expect(cycleSort(array)).toEqual([1, 2, 3, 4, 5])
|
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]
|
const array = [15, 24, 3, 2224, 1]
|
||||||
expect(cycleSort(array)).toEqual([1, 3, 15, 24, 2224])
|
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', () => {
|
it('should return an empty list with the input list is an empty list', () => {
|
||||||
expect(cycleSort([])).toEqual([])
|
expect(cycleSort([])).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(cycleSort([40, 42, 56, 45, 12, 3])).toEqual([3, 12, 40, 42, 45, 56])
|
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', () => {
|
it('should correctly sort an input list that contains only positive numbers', () => {
|
||||||
expect(cycleSort([50, 33, 11, 2])).toEqual([2, 11, 33, 50])
|
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', () => {
|
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])
|
expect(cycleSort([4, 3, 4, 2, 1, 2])).toEqual([1, 2, 2, 3, 4, 4])
|
||||||
})
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user