-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmcConstants.test.js
More file actions
74 lines (69 loc) · 2.52 KB
/
cmcConstants.test.js
File metadata and controls
74 lines (69 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { assert } from './test-utils/deps-node.js';
import {
CMC_APP_CODES,
CMC_EVENT_TYPES,
appSubScope,
extractAppSubScopeSuffix
} from '../ts/cmc/constants.ts';
/**
* Unit tests for the Plan 60 B2 shared CMC constants + scope helpers.
*
* The constants are locked per Plan 59 Decisions; tests assert the exact
* values so any drift becomes a deliberate change with an explicit diff.
*/
describe('[CCST] cmcConstants', function () {
describe('[CCSA] CMC_APP_CODES', function () {
it('[CCS01] PATIENT, COLLECTOR, BRIDGE_MIRA, BRIDGE_ATHENA match locked values', () => {
assert.equal(CMC_APP_CODES.PATIENT, 'hds-patient');
assert.equal(CMC_APP_CODES.COLLECTOR, 'hds-collector');
assert.equal(CMC_APP_CODES.BRIDGE_MIRA, 'hds-bridge-mira');
assert.equal(CMC_APP_CODES.BRIDGE_ATHENA, 'hds-bridge-athena');
});
});
describe('[CCSE] CMC_EVENT_TYPES', function () {
it('[CCS10] INVITE_TRIGGER + ACCEPT match the CMC plugin convention', () => {
assert.equal(CMC_EVENT_TYPES.INVITE_TRIGGER, 'consent/request-cmc');
assert.equal(CMC_EVENT_TYPES.ACCEPT, 'consent/accept-cmc');
});
});
describe('[CCSB] appSubScope', function () {
it('[CCS20] builds the canonical sub-scope id', () => {
assert.equal(
appSubScope(CMC_APP_CODES.COLLECTOR, 'abc123'),
':_cmc:apps:hds-collector:abc123'
);
});
it('[CCS21] composes deeper paths via colon-joined sub', () => {
assert.equal(
appSubScope(CMC_APP_CODES.PATIENT, 'chats:dr-smith'),
':_cmc:apps:hds-patient:chats:dr-smith'
);
});
});
describe('[CCSX] extractAppSubScopeSuffix', function () {
it('[CCS30] strips the appScope prefix', () => {
assert.equal(
extractAppSubScopeSuffix(':_cmc:apps:hds-collector:abc123', CMC_APP_CODES.COLLECTOR),
'abc123'
);
});
it('[CCS31] tolerates leading prefix (matches original .*? regex behavior)', () => {
assert.equal(
extractAppSubScopeSuffix('peer:_cmc:apps:hds-collector:abc123', CMC_APP_CODES.COLLECTOR),
'abc123'
);
});
it('[CCS32] returns streamId unchanged when prefix absent', () => {
assert.equal(
extractAppSubScopeSuffix(':some-other-stream', CMC_APP_CODES.COLLECTOR),
':some-other-stream'
);
});
it('[CCS33] does not cross-match a different appCode', () => {
assert.equal(
extractAppSubScopeSuffix(':_cmc:apps:hds-collector:abc', CMC_APP_CODES.PATIENT),
':_cmc:apps:hds-collector:abc'
);
});
});
});