| 1 | // FEP-633c §2.2: shaer:hasGuardians object hint (outbound stamp + register).
|
|---|
| 2 | import { test } from 'node:test';
|
|---|
| 3 | import assert from 'node:assert/strict';
|
|---|
| 4 |
|
|---|
| 5 | process.env.DATABASE_PATH = ':memory:';
|
|---|
| 6 | process.env.PUBLIC_BASE_URL = 'https://test.example';
|
|---|
| 7 |
|
|---|
| 8 | const dbMod = await import('../src/config/database.js');
|
|---|
| 9 | const db = dbMod.default;
|
|---|
| 10 | dbMod.initializeDatabase();
|
|---|
| 11 | const G = await import('../src/services/guardianship/index.js');
|
|---|
| 12 |
|
|---|
| 13 | db.prepare('INSERT INTO users (id, username, email, password_hash, role) VALUES (?,?,?,?,?)').run('u1','u1','u1@t','x','god');
|
|---|
| 14 | db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,1)').run('s1','kid','kid','u1');
|
|---|
| 15 | db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,0)').run('s2','free','free','u1');
|
|---|
| 16 | db.prepare("INSERT INTO ap_guardianships (slug, role, other_uri, status, created_at) VALUES ('kid','ward','https://m.example/mom','accepted',CURRENT_TIMESTAMP)").run();
|
|---|
| 17 |
|
|---|
| 18 | test('a ward stamps the hint; a free actor does not', () => {
|
|---|
| 19 | assert.deepEqual(G.hasGuardiansProps('kid'), { 'shaer:hasGuardians': true });
|
|---|
| 20 | assert.deepEqual(G.hasGuardiansProps('free'), {});
|
|---|
| 21 | });
|
|---|
| 22 |
|
|---|
| 23 | test('objectHasGuardians reads the hint, register-only', () => {
|
|---|
| 24 | assert.equal(G.objectHasGuardians({ 'shaer:hasGuardians': true }), true);
|
|---|
| 25 | assert.equal(G.objectHasGuardians({}), false);
|
|---|
| 26 | });
|
|---|