feat: minimal signals + RemoteData template with a users feature
Extracted from atomic-design-poc: RemoteData<E,T> (bare union + fromResource, no combinators) + a trimmed <app-async> switch, no Elm-style store — state is resource() plus one plain signal. Minimal DDD layering per context (domain/infrastructure/application/ui) combined with atomic design inside ui/ (atoms/molecules/organisms/templates/pages), mirroring the POC's conventions at template scale. One worked feature (users/): a list with a click-through to a detail view (its own independent resource() fetch) and a Back action. Tests are BDD-style (describe/it, one assertion per it) and black-box (assert rendered DOM/emitted events only) - 100% branch/line coverage. README.md documents what's deliberately omitted vs. the POC and the concrete growth path back to it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { isEmptyUserList } from './user';
|
||||
|
||||
describe('isEmptyUserList', () => {
|
||||
it('is empty for an empty list', () => {
|
||||
expect(isEmptyUserList([])).toBe(true);
|
||||
});
|
||||
|
||||
it('is not empty when a user is present', () => {
|
||||
expect(isEmptyUserList([{ id: 1, name: 'Ada' }])).toBe(false);
|
||||
});
|
||||
|
||||
it('is empty when the list is undefined', () => {
|
||||
expect(isEmptyUserList(undefined)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface UserDetail extends User {
|
||||
email: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts `undefined` because a resource's value is `T | undefined` until it resolves
|
||||
* (no `defaultValue` is set) — `fromResource` only calls this once `hasValue()` is true,
|
||||
* but the type can't express that across the generic boundary.
|
||||
*/
|
||||
export const isEmptyUserList = (users: User[] | undefined): boolean => !users || users.length === 0;
|
||||
Reference in New Issue
Block a user