Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# GitHub Copilot Instructions

## Testing

- Use the `node:test` framework and `assert` for assertions.
- When generating tests, add them to the existing test file for the relevant module.
- Use a new describe block if the function being tested does not already have one.
- Follow existing conventions for test names, structure, and assertions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createTiff, Url } from '../../common.ts';
import {
commandTileIndexValidate,
extractTiffLocations,
getSize,
getTileName,
GridSizeFromString,
groupByTileName,
Expand All @@ -28,6 +29,32 @@ import { FakeCogTiff } from './tileindex.validate.data.ts';

/* eslint-disable @typescript-eslint/no-explicit-any */

describe('getSize', () => {
it('should return correct width and height for positive extent', () => {
const extent: [number, number, number, number] = [10, 20, 30, 40];
const size = getSize(extent);
assert.deepEqual(size, { width: 20, height: 20 });
});

it('should return zero width and height for zero-size extent', () => {
const extent: [number, number, number, number] = [5, 5, 5, 5];
const size = getSize(extent);
assert.deepEqual(size, { width: 0, height: 0 });
});

it('should handle negative coordinates correctly', () => {
const extent: [number, number, number, number] = [-10, -20, 10, 20];
const size = getSize(extent);
assert.deepEqual(size, { width: 20, height: 40 });
});

it('should handle reversed coordinates (min > max)', () => {
const extent: [number, number, number, number] = [30, 40, 10, 20];
const size = getSize(extent);
assert.deepEqual(size, { width: -20, height: -20 });
});
});

function convertTileName(fileName: string, gridSize: GridSize): string | null {
const mapTileIndex = MapSheet.getMapTileIndex(fileName);
if (mapTileIndex == null) return null;
Expand Down