Download benchmarks/reference/js-pagination.test.js from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/reference/js-pagination.test.js
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/reference/js-pagination.test.js
-
curl -L -o js-pagination.test.js https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/reference/js-pagination.test.js
1.62 kB
| const { pageCount, clampPage, pageItems, pageButtons } = require('./solution'); | |
| describe('pageCount', () => { | |
| test('rounds up and has at least one page', () => { | |
| expect(pageCount(10, 3)).toBe(4); | |
| expect(pageCount(9, 3)).toBe(3); | |
| expect(pageCount(0, 5)).toBe(1); | |
| }); | |
| test('validates arguments', () => { | |
| expect(() => pageCount(5, 0)).toThrow(RangeError); | |
| expect(() => pageCount(5, 2.5)).toThrow(RangeError); | |
| expect(() => pageCount(-1, 5)).toThrow(RangeError); | |
| }); | |
| }); | |
| test('clampPage', () => { | |
| expect(clampPage(0, 4)).toBe(1); | |
| expect(clampPage(9, 4)).toBe(4); | |
| expect(clampPage(3, 4)).toBe(3); | |
| }); | |
| describe('pageItems', () => { | |
| const items = [1, 2, 3, 4, 5, 6, 7]; | |
| test('returns the requested page', () => { | |
| expect(pageItems(items, 1, 3)).toEqual([1, 2, 3]); | |
| expect(pageItems(items, 3, 3)).toEqual([7]); | |
| }); | |
| test('clamps out-of-range pages', () => { | |
| expect(pageItems(items, 99, 3)).toEqual([7]); | |
| expect(pageItems(items, -2, 3)).toEqual([1, 2, 3]); | |
| }); | |
| }); | |
| describe('pageButtons', () => { | |
| test('all pages when few', () => { | |
| expect(pageButtons(2, 3)).toEqual([1, 2, 3]); | |
| expect(pageButtons(1, 1)).toEqual([1]); | |
| }); | |
| test('ellipses on both sides', () => { | |
| expect(pageButtons(5, 10)).toEqual([1, '…', 4, 5, 6, '…', 10]); | |
| }); | |
| test('single-page gap is filled with the page itself', () => { | |
| expect(pageButtons(4, 10)).toEqual([1, 2, 3, 4, 5, '…', 10]); | |
| }); | |
| test('window size', () => { | |
| expect(pageButtons(5, 10, 2)).toEqual([1, 2, 3, 4, 5, 6, 7, '…', 10]); | |
| expect(pageButtons(1, 10, 0)).toEqual([1, '…', 10]); | |
| }); | |
| }); | |