@payloadcms/db-mongodb 4.0.0-internal.af6aad0 → 4.0.0-internal.b8a92d2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,215 +0,0 @@
1
- import { describe, beforeAll, it, expect } from 'vitest';
2
- import { flattenAllFields, sanitizeConfig } from 'payload';
3
- import { getLocalizedSortProperty } from './getLocalizedSortProperty.js';
4
- let config;
5
- describe('get localized sort property', ()=>{
6
- beforeAll(async ()=>{
7
- config = sanitizeConfig({
8
- localization: {
9
- defaultLocale: 'en',
10
- fallback: true,
11
- locales: [
12
- 'en',
13
- 'es'
14
- ]
15
- }
16
- });
17
- });
18
- it('passes through a non-localized sort property', ()=>{
19
- const result = getLocalizedSortProperty({
20
- config,
21
- parentIsLocalized: false,
22
- fields: [
23
- {
24
- name: 'title',
25
- type: 'text'
26
- }
27
- ],
28
- locale: 'en',
29
- segments: [
30
- 'title'
31
- ]
32
- });
33
- expect(result).toStrictEqual('title');
34
- });
35
- it('properly localizes an un-localized sort property', ()=>{
36
- const result = getLocalizedSortProperty({
37
- config,
38
- parentIsLocalized: false,
39
- fields: [
40
- {
41
- name: 'title',
42
- type: 'text',
43
- localized: true
44
- }
45
- ],
46
- locale: 'en',
47
- segments: [
48
- 'title'
49
- ]
50
- });
51
- expect(result).toStrictEqual('title.en');
52
- });
53
- it('keeps specifically asked-for localized sort properties', ()=>{
54
- const result = getLocalizedSortProperty({
55
- config,
56
- parentIsLocalized: false,
57
- fields: [
58
- {
59
- name: 'title',
60
- type: 'text',
61
- localized: true
62
- }
63
- ],
64
- locale: 'en',
65
- segments: [
66
- 'title',
67
- 'es'
68
- ]
69
- });
70
- expect(result).toStrictEqual('title.es');
71
- });
72
- it('properly localizes nested sort properties', ()=>{
73
- const result = getLocalizedSortProperty({
74
- config,
75
- parentIsLocalized: false,
76
- fields: flattenAllFields({
77
- fields: [
78
- {
79
- name: 'group',
80
- type: 'group',
81
- fields: [
82
- {
83
- name: 'title',
84
- type: 'text',
85
- localized: true
86
- }
87
- ]
88
- }
89
- ]
90
- }),
91
- locale: 'en',
92
- segments: [
93
- 'group',
94
- 'title'
95
- ]
96
- });
97
- expect(result).toStrictEqual('group.title.en');
98
- });
99
- it('keeps requested locale with nested sort properties', ()=>{
100
- const result = getLocalizedSortProperty({
101
- config,
102
- parentIsLocalized: false,
103
- fields: flattenAllFields({
104
- fields: [
105
- {
106
- name: 'group',
107
- type: 'group',
108
- fields: [
109
- {
110
- name: 'title',
111
- type: 'text',
112
- localized: true
113
- }
114
- ]
115
- }
116
- ]
117
- }),
118
- locale: 'en',
119
- segments: [
120
- 'group',
121
- 'title',
122
- 'es'
123
- ]
124
- });
125
- expect(result).toStrictEqual('group.title.es');
126
- });
127
- it('properly localizes field within row', ()=>{
128
- const result = getLocalizedSortProperty({
129
- config,
130
- parentIsLocalized: false,
131
- fields: flattenAllFields({
132
- fields: [
133
- {
134
- type: 'row',
135
- fields: [
136
- {
137
- name: 'title',
138
- type: 'text',
139
- localized: true
140
- }
141
- ]
142
- }
143
- ]
144
- }),
145
- locale: 'en',
146
- segments: [
147
- 'title'
148
- ]
149
- });
150
- expect(result).toStrictEqual('title.en');
151
- });
152
- it('properly localizes field within named tab', ()=>{
153
- const result = getLocalizedSortProperty({
154
- config,
155
- parentIsLocalized: false,
156
- fields: flattenAllFields({
157
- fields: [
158
- {
159
- type: 'tabs',
160
- tabs: [
161
- {
162
- name: 'tab',
163
- fields: [
164
- {
165
- name: 'title',
166
- type: 'text',
167
- localized: true
168
- }
169
- ]
170
- }
171
- ]
172
- }
173
- ]
174
- }),
175
- locale: 'en',
176
- segments: [
177
- 'tab',
178
- 'title'
179
- ]
180
- });
181
- expect(result).toStrictEqual('tab.title.en');
182
- });
183
- it('properly localizes field within unnamed tab', ()=>{
184
- const result = getLocalizedSortProperty({
185
- config,
186
- parentIsLocalized: false,
187
- fields: flattenAllFields({
188
- fields: [
189
- {
190
- type: 'tabs',
191
- tabs: [
192
- {
193
- fields: [
194
- {
195
- name: 'title',
196
- type: 'text',
197
- localized: true
198
- }
199
- ],
200
- label: 'Tab'
201
- }
202
- ]
203
- }
204
- ]
205
- }),
206
- locale: 'en',
207
- segments: [
208
- 'title'
209
- ]
210
- });
211
- expect(result).toStrictEqual('title.en');
212
- });
213
- });
214
-
215
- //# sourceMappingURL=getLocalizedSortProperty.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/getLocalizedSortProperty.spec.ts"],"sourcesContent":["import { describe, beforeAll, it, expect } from 'vitest'\nimport type { Config, SanitizedConfig } from 'payload'\nimport { flattenAllFields, sanitizeConfig } from 'payload'\n\nimport { getLocalizedSortProperty } from './getLocalizedSortProperty.js'\n\nlet config: SanitizedConfig\n\ndescribe('get localized sort property', () => {\n beforeAll(async () => {\n config = sanitizeConfig({\n localization: {\n defaultLocale: 'en',\n fallback: true,\n locales: ['en', 'es'],\n },\n } as Config)\n })\n it('passes through a non-localized sort property', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title')\n })\n\n it('properly localizes an un-localized sort property', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title.en')\n })\n\n it('keeps specifically asked-for localized sort properties', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n locale: 'en',\n segments: ['title', 'es'],\n })\n\n expect(result).toStrictEqual('title.es')\n })\n\n it('properly localizes nested sort properties', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: flattenAllFields({\n fields: [\n {\n name: 'group',\n type: 'group',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n }),\n locale: 'en',\n segments: ['group', 'title'],\n })\n\n expect(result).toStrictEqual('group.title.en')\n })\n\n it('keeps requested locale with nested sort properties', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: flattenAllFields({\n fields: [\n {\n name: 'group',\n type: 'group',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n }),\n locale: 'en',\n segments: ['group', 'title', 'es'],\n })\n\n expect(result).toStrictEqual('group.title.es')\n })\n\n it('properly localizes field within row', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: flattenAllFields({\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n }),\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title.en')\n })\n\n it('properly localizes field within named tab', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: flattenAllFields({\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n name: 'tab',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ],\n }),\n locale: 'en',\n segments: ['tab', 'title'],\n })\n\n expect(result).toStrictEqual('tab.title.en')\n })\n\n it('properly localizes field within unnamed tab', () => {\n const result = getLocalizedSortProperty({\n config,\n parentIsLocalized: false,\n fields: flattenAllFields({\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n label: 'Tab',\n },\n ],\n },\n ],\n }),\n locale: 'en',\n segments: ['title'],\n })\n\n expect(result).toStrictEqual('title.en')\n })\n})\n"],"names":["describe","beforeAll","it","expect","flattenAllFields","sanitizeConfig","getLocalizedSortProperty","config","localization","defaultLocale","fallback","locales","result","parentIsLocalized","fields","name","type","locale","segments","toStrictEqual","localized","tabs","label"],"mappings":"AAAA,SAASA,QAAQ,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