File tree Expand file tree Collapse file tree 6 files changed +51
-2
lines changed
fixtures/collect-placeholders-sorting Expand file tree Collapse file tree 6 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,39 @@ describe("Catalog", () => {
193193 expect ( messages ) . toMatchSnapshot ( )
194194 } )
195195
196+ it ( "should sort placeholders to keep them stable between runs" , async ( ) => {
197+ const runA = await extractFromFiles (
198+ [
199+ fixture ( "collect-placeholders-sorting/a.ts" ) ,
200+ fixture ( "collect-placeholders-sorting/b.ts" ) ,
201+ ] ,
202+ mockConfig ( )
203+ )
204+
205+ const runB = await extractFromFiles (
206+ [
207+ fixture ( "collect-placeholders-sorting/b.ts" ) ,
208+ fixture ( "collect-placeholders-sorting/a.ts" ) ,
209+ ] ,
210+ mockConfig ( )
211+ )
212+
213+ expect ( Object . values ( runA ) [ 0 ] . placeholders [ 0 ] ) . toStrictEqual (
214+ Object . values ( runB ) [ 0 ] . placeholders [ 0 ]
215+ )
216+
217+ expect ( Object . values ( runA ) [ 0 ] . placeholders ) . toMatchInlineSnapshot ( `
218+ {
219+ 0: [
220+ getUser(),
221+ getWorld(),
222+ ],
223+ }
224+ ` )
225+
226+ // expect(messages).toMatchSnapshot()
227+ } )
228+
196229 it ( "should support experimental typescript decorators under a flag" , async ( ) => {
197230 const messages = await extractFromFiles (
198231 [ fixture ( "collect-typescript-jsx/tsx-experimental-decorators.tsx" ) ] ,
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ function mergePlaceholders(
2323 if ( ! res [ key ] . includes ( value ) ) {
2424 res [ key ] . push ( value )
2525 }
26+
27+ res [ key ] . sort ( )
2628 } )
2729
2830 return res
Original file line number Diff line number Diff line change 1+ import { t } from "@lingui/core/macro" ;
2+
3+ function getUser ( ) {
4+ return 'John'
5+ }
6+
7+ t `Hello ${ getUser ( ) } `
Original file line number Diff line number Diff line change 1+ import { t } from "@lingui/core/macro"
2+
3+ function getWorld ( ) {
4+ return "John"
5+ }
6+
7+ t `Hello ${ getWorld ( ) } `
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ msgstr ""
1313msgid "addToCart"
1414msgstr "Add To Cart"
1515
16- #. placeholder {0}: user.name
1716#. placeholder {0}: author.name
1817#. placeholder {0}: moderator.name
18+ #. placeholder {0}: user.name
1919#: fixtures/placeholders.ts:3
2020#: fixtures/placeholders.ts:4
2121#: fixtures/placeholders.ts:5
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ msgstr ""
1313msgid "addToCart"
1414msgstr ""
1515
16- #. placeholder {0}: user.name
1716#. placeholder {0}: author.name
1817#. placeholder {0}: moderator.name
18+ #. placeholder {0}: user.name
1919#: fixtures/placeholders.ts:3
2020#: fixtures/placeholders.ts:4
2121#: fixtures/placeholders.ts:5
You can’t perform that action at this time.
0 commit comments