mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 02:34:21 +00:00
feat: quality of life sweep from the feature discussions
Small requests from the discussions, each built end to end: planner and map (cycling mode, date first headings, clear a day, stay times per day, off-route stops, map lock, compact unplanned markers, pending stays, cable car, transit quick picks), places (location filter, category from OSM, open in maps, geo: link, image from an attachment, enrichment on file import, places near a pin, place name language, Amap first in China), lists and costs (packed counter, inherited sharing, Markdown to-dos, payment notes, bookings CSV, my plan PDF), sharing (unplanned places, travel only, without photos), journey (photo zoom, drafts, photo order, trip suggestion, day jump), atlas (region counter, region bucket list, places per country), vacay half company holidays, studio copy and paste plus the book's own layouts, and RESTORE_FROM_BACKUP for a first start restore.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { resolvePackedState } from './packed-count';
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
const open = { checked: 0, packed_quantity: null };
|
||||
|
||||
describe('resolvePackedState (#2296)', () => {
|
||||
it('PACKED-001: keeps a partial count and leaves the box unticked', () => {
|
||||
expect(resolvePackedState(open, { bodyKeys: ['packed_quantity'], packed_quantity: 4, quantity: 10 })).toEqual({
|
||||
checked: 0,
|
||||
packed_quantity: 4,
|
||||
});
|
||||
});
|
||||
|
||||
it('PACKED-002: a full or overfull count ticks the item and drops the count', () => {
|
||||
expect(resolvePackedState(open, { bodyKeys: ['packed_quantity'], packed_quantity: 10, quantity: 10 })).toEqual({
|
||||
checked: 1,
|
||||
packed_quantity: null,
|
||||
});
|
||||
expect(resolvePackedState(open, { bodyKeys: ['packed_quantity'], packed_quantity: 99, quantity: 10 })).toEqual({
|
||||
checked: 1,
|
||||
packed_quantity: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('PACKED-003: zero or null clears the count and unticks a finished item', () => {
|
||||
const done = { checked: 1, packed_quantity: null };
|
||||
expect(resolvePackedState(done, { bodyKeys: ['packed_quantity'], packed_quantity: 0, quantity: 3 })).toEqual({
|
||||
checked: 0,
|
||||
packed_quantity: null,
|
||||
});
|
||||
expect(resolvePackedState(done, { bodyKeys: ['packed_quantity'], packed_quantity: null, quantity: 3 })).toEqual({
|
||||
checked: 0,
|
||||
packed_quantity: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('PACKED-004: the box decides for the whole item', () => {
|
||||
const partial = { checked: 0, packed_quantity: 2 };
|
||||
expect(resolvePackedState(partial, { bodyKeys: ['checked'], checked: 1, quantity: 5 })).toEqual({
|
||||
checked: 1,
|
||||
packed_quantity: null,
|
||||
});
|
||||
expect(resolvePackedState(partial, { bodyKeys: ['checked'], checked: 0, quantity: 5 })).toEqual({
|
||||
checked: 0,
|
||||
packed_quantity: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('PACKED-005: a lowered quantity the count reaches finishes the item, anything else is left alone', () => {
|
||||
const partial = { checked: 0, packed_quantity: 4 };
|
||||
expect(resolvePackedState(partial, { bodyKeys: ['quantity'], quantity: 4 })).toEqual({
|
||||
checked: 1,
|
||||
packed_quantity: null,
|
||||
});
|
||||
expect(resolvePackedState(partial, { bodyKeys: ['quantity'], quantity: 8 })).toBe(partial);
|
||||
expect(resolvePackedState(partial, { bodyKeys: ['name'], quantity: 8 })).toBe(partial);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user