mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 22:46:32 +00:00
09caf4bc3f
The checklist and the obstacle data sorted texts without a compare function. They now sort by code units through one shared compareCodeUnits, the order a bare sort gave, the same on every machine; the material data of a lock's parts no longer orders by the server's locale, so its hash cannot change with it. The note editor takes the focus through a ref instead of autoFocus, a direct function reference in a map becomes a call, and the GPX import's default fields are a named constant.
14 lines
536 B
TypeScript
14 lines
536 B
TypeScript
import { compareCodeUnits } from './compare';
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('compareCodeUnits', () => {
|
|
it('orders as a bare sort does, whatever the locale', () => {
|
|
const texts = ['way/3', 'node/10', 'node/2', 'Node/1', 'check_date', 'canoe', '2026-09-30', '2026-10-01'];
|
|
expect([...texts].sort(compareCodeUnits)).toEqual([...texts].sort());
|
|
expect(compareCodeUnits('a', 'a')).toBe(0);
|
|
expect(compareCodeUnits('a', 'b')).toBe(-1);
|
|
expect(compareCodeUnits('b', 'a')).toBe(1);
|
|
});
|
|
});
|