🧪 Simplify and improve test cases for expandDisplayLinesToInclude in useGamemasterFiles composable
This commit is contained in:
@@ -359,34 +359,27 @@ describe('useGamemasterFiles', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('expandDisplayLinesToInclude', () => {
|
describe('expandDisplayLinesToInclude', () => {
|
||||||
beforeEach(async () => {
|
|
||||||
// Create large file with many items that will create many lines
|
|
||||||
const largeData = {
|
|
||||||
items: Array(15000).fill({ id: 1, data: 'test' })
|
|
||||||
};
|
|
||||||
mockClient.getPokemon.mockResolvedValueOnce(largeData);
|
|
||||||
composable.selectedFile.value = 'pokemon';
|
|
||||||
await composable.loadFile();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not expand if line is visible', () => {
|
it('should not expand if line is visible', () => {
|
||||||
|
composable.fileLines.value = Array(500).fill('line');
|
||||||
|
composable.updateDisplayLines(0, 100);
|
||||||
const originalLength = composable.displayLines.value.length;
|
const originalLength = composable.displayLines.value.length;
|
||||||
composable.expandDisplayLinesToInclude(100);
|
|
||||||
|
composable.expandDisplayLinesToInclude(50);
|
||||||
|
|
||||||
expect(composable.displayLines.value.length).toBe(originalLength);
|
expect(composable.displayLines.value.length).toBe(originalLength);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should expand to include line number', () => {
|
it('should expand to include requested line', () => {
|
||||||
if (composable.fileLines.value.length > 15000) {
|
composable.fileLines.value = Array(500).fill('line');
|
||||||
composable.expandDisplayLinesToInclude(15000);
|
composable.updateDisplayLines(0, 100);
|
||||||
|
|
||||||
expect(composable.displayLines.value.length).toBeGreaterThan(
|
composable.expandDisplayLinesToInclude(300);
|
||||||
composable.LINES_TO_DISPLAY
|
|
||||||
);
|
expect(composable.displayLines.value.length).toBeGreaterThan(100);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not exceed total file lines', () => {
|
it('should not exceed total file lines', () => {
|
||||||
|
composable.fileLines.value = Array(500).fill('line');
|
||||||
composable.expandDisplayLinesToInclude(999999);
|
composable.expandDisplayLinesToInclude(999999);
|
||||||
|
|
||||||
expect(composable.displayLines.value.length).toBeLessThanOrEqual(
|
expect(composable.displayLines.value.length).toBeLessThanOrEqual(
|
||||||
|
|||||||
Reference in New Issue
Block a user