Skip to content

Instantly share code, notes, and snippets.

@sigmadream
Last active September 11, 2025 03:26
Show Gist options
  • Save sigmadream/eed76605069e8e4ccf9fdafd27f204c6 to your computer and use it in GitHub Desktop.
Save sigmadream/eed76605069e8e4ccf9fdafd27f204c6 to your computer and use it in GitHub Desktop.
간단한 정렬 테스트 코드
import { simpleSort } from '@/sort';
import '@jest/globals';
describe('숫자 정렬 함수', () => {
test('기본적인 정렬 동작', () => {
expect(simpleSort([3, 1, 2])).toEqual([1, 2, 3]);
expect(simpleSort([10, -5, 0, 2])).toEqual([-5, 0, 2, 10]);
expect(simpleSort([1])).toEqual([1]);
expect(simpleSort([])).toEqual([]);
expect(simpleSort([0, -1, 1, -2, 2])).toEqual([-2, -1, 0, 1, 2]);
expect(simpleSort([1, 2, 3, 4, 5])).toEqual([1, 2, 3, 4, 5]);
expect(simpleSort([2, 3, 2, 1, 1])).toEqual([1, 1, 2, 2, 3]);
});
});
describe('숫자 내림차순 정렬 함수', () => {
test('기본적인 정렬 동작', () => {
expect(simpleSort([3, 1, 2], 'desc')).toEqual([3, 2, 1]);
expect(simpleSort([10, -5, 0, 2], 'desc')).toEqual([10, 2, 0, -5]);
expect(simpleSort([1], 'desc')).toEqual([1]);
expect(simpleSort([], 'desc')).toEqual([]);
expect(simpleSort([0, -1, 1, -2, 2], 'desc')).toEqual([2, 1, 0, -1, -2]);
expect(simpleSort([5, 4, 3, 2, 1], 'desc')).toEqual([5, 4, 3, 2, 1]);
expect(simpleSort([3, 2, 2, 1, 1], 'desc')).toEqual([3, 2, 2, 1, 1]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment