Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbffc9dc

Browse files
committed
test(i18n): add test cases to make sure custom remote from prop takes precedence over context
1 parent20d705f commitbffc9dc

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

‎packages/i18n/src/runtime/tests/remote/browser.test.svelte.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function r(
3939
expects:{en:string;vi:string},
4040
){
4141
letremote=defaultRemote;
42-
constcustomRemote=contextInit.remote??props.remote;
42+
constcustomRemote=props.remote??contextInit.remote;
4343
if(customRemote){
4444
if(customRemote==='query'){
4545
remote=remoteQuery;
@@ -183,7 +183,7 @@ describe('can render with key with params', () => {
183183
});
184184
});
185185

186-
describe('as remote as function',()=>{
186+
describe('custom remote as function',()=>{
187187
constrendered='from custom remote';
188188
constremote=vi.fn().mockImplementation(()=>rendered);
189189

@@ -267,6 +267,22 @@ describe(`custom remote as "prerender"`, () => {
267267
});
268268
});
269269

270+
test('custom remote prop should take precedence over context',async()=>{
271+
awaitr(
272+
{lang:'en',remote:'prerender'},
273+
{
274+
key:messages.withParams.$k,
275+
params:{name:'foobar'},
276+
lang:'vi',
277+
remote:'query',
278+
},
279+
{
280+
en:messages.withParams('en',{name:'foobar'}),
281+
vi:messages.withParams('vi',{name:'foobar'}),
282+
},
283+
);
284+
});
285+
270286
describe('can santize',()=>{
271287
test.todo('by default',async()=>{});
272288
test.todo('via santize prop',async()=>{});

‎packages/i18n/src/runtime/tests/remote/ssr.test.svelte.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ describe('can custom remote function', () => {
165165
});
166166
});
167167

168+
test('prop should take precedence over context',async()=>{
169+
constrendered='from custom remote';
170+
constremote=vi.fn().mockImplementation(()=>rendered);
171+
const{ body}=awaitrender(InProvider,{
172+
props:{
173+
t:{
174+
key:messages.withParams.$k,
175+
params:{name:'foobar'},
176+
remote,
177+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
178+
}asany,
179+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
180+
context:{lang:'en',remote:'prerender'}asany,
181+
},
182+
});
183+
expect(body).toContain(rendered);
184+
});
185+
168186
for(constremoteof['query','prerender']asconst){
169187
describe(`as "${remote}"`,()=>{
170188
test('via context',async()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp