Skip to content

Commit 992d086

Browse files
committed
test(rsc-mf): cover alias trim dedupe in callback registration
1 parent 6638c75 commit 992d086

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/integration/rsc-mf/tests/registerServerCallback.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,30 @@ describe('registerRemoteServerCallback runtime behavior', () => {
122122
);
123123
});
124124

125+
it('trims alias before callback keying and action prefixing', async () => {
126+
const { registerRemoteServerCallback } = await importRegisterHelper();
127+
registerRemoteServerCallback(
128+
'http://127.0.0.1:3008/server-component-root',
129+
' rscRemote ',
130+
);
131+
registerRemoteServerCallback(
132+
'http://127.0.0.1:3008/server-component-root',
133+
'rscRemote',
134+
);
135+
expect(mockSetServerCallback).toHaveBeenCalledTimes(1);
136+
137+
const callback = getRegisteredCallback();
138+
await callback('trimmed-alias-action', []);
139+
expect(global.fetch).toHaveBeenCalledWith(
140+
'http://127.0.0.1:3008/server-component-root',
141+
expect.objectContaining({
142+
headers: expect.objectContaining({
143+
'x-rsc-action': 'remote:rscRemote:trimmed-alias-action',
144+
}),
145+
}),
146+
);
147+
});
148+
125149
it('ignores empty callback origins after trimming', async () => {
126150
const { registerRemoteServerCallback } = await importRegisterHelper();
127151
registerRemoteServerCallback(' ');

0 commit comments

Comments
 (0)