Autotiles are a new asset type with a tab that shows every tile of the floor (2x3) or wall (2x2) block and an animated sample pattern (#118)
game-maker / gate (push) Successful in 1m50s
game-maker / suite (push) Successful in 5m59s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-17 21:35:29 +02:00
1 parent c17b2b5426
commit 1a9f07c4ac
24 files changed
+1797 -18

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest';
import { dropIndex } from '../../src/editor/autotile/PictureStrip';
/**
* Reordering the pictures of an autotile by dragging a row (#118). The index the move command
* takes counts in the list without the dragged row, which is where the off-by-ones live.
*/
describe('dropping a picture row', () => {
it('takes the place of the row it is dropped on', () => {
expect(dropIndex(0, { at: 'onto', targetId: '1' }, 3)).toBe(1);
expect(dropIndex(2, { at: 'onto', targetId: '0' }, 3)).toBe(0);
// Dropping a row on itself is nothing to do – which is also what the list reports as no spot.
expect(dropIndex(1, { at: 'onto', targetId: '1' }, 3)).toBe(1);
});
it('counts a gap in the list the row has already left', () => {
// Downwards: the gap below row 1 is index 1 once row 0 is out of the way.
expect(dropIndex(0, { at: 'after', targetId: '1' }, 3)).toBe(1);
expect(dropIndex(0, { at: 'before', targetId: '2' }, 3)).toBe(1);
// Upwards nothing shifts: the gap above row 0 stays index 0.
expect(dropIndex(2, { at: 'before', targetId: '0' }, 3)).toBe(0);
expect(dropIndex(2, { at: 'after', targetId: '0' }, 3)).toBe(1);
expect(dropIndex(1, { at: 'end' }, 3)).toBe(2);
});
it('refuses a row or a target that is not in the list', () => {
expect(dropIndex(-1, { at: 'end' }, 3)).toBe(-1);
expect(dropIndex(3, { at: 'end' }, 3)).toBe(-1);
expect(dropIndex(0, { at: 'onto', targetId: '9' }, 3)).toBe(-1);
expect(dropIndex(0, { at: 'before', targetId: 'nonsense' }, 3)).toBe(-1);
});
});