@jsb188/app 1.1.10 → 1.1.12

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.
Files changed (79) hide show
  1. package/package.json +57 -45
  2. package/src/constants/agent.ts +51 -41
  3. package/src/constants/app.ts +34 -13
  4. package/src/constants/emoji.ts +9144 -8936
  5. package/src/constants/other.ts +1 -5
  6. package/src/constants/user.ts +16 -25
  7. package/src/constants/wsActions.ts +27 -0
  8. package/src/i18n/account.ts +129 -107
  9. package/src/i18n/agent.ts +331 -73
  10. package/src/i18n/agentToolBusiness.ts +196 -0
  11. package/src/i18n/agentToolGrid.ts +137 -0
  12. package/src/i18n/agentToolWorkflow.ts +101 -0
  13. package/src/i18n/agent_note.ts +109 -0
  14. package/src/i18n/app.ts +107 -91
  15. package/src/i18n/auth.ts +117 -102
  16. package/src/i18n/billing.ts +5 -92
  17. package/src/i18n/c.ts +907 -0
  18. package/src/i18n/campaign.ts +919 -0
  19. package/src/i18n/country.ts +248 -248
  20. package/src/i18n/datetime.ts +32 -26
  21. package/src/i18n/editor.ts +58 -0
  22. package/src/i18n/error.ts +577 -192
  23. package/src/i18n/field_doc_editor.ts +21 -0
  24. package/src/i18n/field_doc_programs.ts +52 -0
  25. package/src/i18n/field_docs.ts +190 -0
  26. package/src/i18n/index.ts +42 -19
  27. package/src/i18n/log.ts +272 -238
  28. package/src/i18n/memory.ts +53 -0
  29. package/src/i18n/message.ts +3 -4
  30. package/src/i18n/note.ts +19 -0
  31. package/src/i18n/org.ts +164 -109
  32. package/src/i18n/schedule.ts +209 -0
  33. package/src/i18n/sheet.ts +333 -4
  34. package/src/i18n/sheet_formula.ts +165 -0
  35. package/src/i18n/workflow.ts +109 -23
  36. package/src/main.ts +68 -64
  37. package/src/platform.ts +90 -49
  38. package/src/types/ai.d.ts +52 -23
  39. package/src/types/app.d.ts +95 -44
  40. package/src/types/auth.d.ts +66 -40
  41. package/src/types/console.d.ts +3 -0
  42. package/src/types/other.d.ts +13 -6
  43. package/src/types.d.ts +12 -14
  44. package/src/utils/account.ts +64 -58
  45. package/src/utils/api.ts +326 -77
  46. package/src/utils/authSession.ts +24 -0
  47. package/src/utils/clientIP.ts +213 -0
  48. package/src/utils/color.ts +279 -0
  49. package/src/utils/cron.ts +49 -18
  50. package/src/utils/csv.ts +19 -0
  51. package/src/utils/datetime.ts +445 -117
  52. package/src/utils/deferredSave.ts +89 -0
  53. package/src/utils/email.ts +50 -0
  54. package/src/utils/emoji.ts +107 -84
  55. package/src/utils/expression.helpers.ts +470 -0
  56. package/src/utils/expression.test.ts +793 -0
  57. package/src/utils/expression.ts +2261 -0
  58. package/src/utils/interval.ts +80 -0
  59. package/src/utils/language.ts +9 -0
  60. package/src/utils/logic.ts +141 -121
  61. package/src/utils/managedSession.ts +34 -0
  62. package/src/utils/managedSessionBff.test.ts +60 -0
  63. package/src/utils/managedSessionBff.ts +117 -0
  64. package/src/utils/number.ts +85 -38
  65. package/src/utils/object.ts +227 -30
  66. package/src/utils/promise.ts +98 -0
  67. package/src/utils/queryReset.ts +266 -0
  68. package/src/utils/recurringTask.ts +60 -0
  69. package/src/utils/schema.ts +293 -0
  70. package/src/utils/string.test.ts +205 -208
  71. package/src/utils/string.ts +426 -463
  72. package/src/utils/timeZone.ts +309 -851
  73. package/src/utils/url_client.ts +145 -72
  74. package/tsconfig.json +10 -10
  75. package/src/constants/billing.ts +0 -146
  76. package/src/i18n/form.ts +0 -376
  77. package/src/i18n/product.ts +0 -76
  78. package/src/types/form.d.ts +0 -97
  79. package/src/utils/billing.ts +0 -134
@@ -2,280 +2,277 @@ import { beforeAll, describe, expect, it } from 'vitest';
2
2
 
3
3
  import { configI18n } from '../main.ts';
4
4
  import {
5
- addIndefiniteArticle,
6
- buildSingleText,
7
- camelCaseToDash,
8
- cn,
9
- convertToInternationalPhone,
10
- escapeCSVValue,
11
- formatPhoneNumber,
12
- formatReferenceNumber,
13
- getAlphanumeric,
14
- getDisplayName,
15
- getNthString,
16
- getSearchNames,
17
- guessFirstName,
18
- isEmail,
19
- isInvisibleString,
20
- isPhone,
21
- joinReadable,
22
- makeAddressText,
23
- passwordStrength,
24
- regexFromText,
25
- removeGeneratedTextGarbage,
26
- shortenToParagraph,
27
- shortenToSpace,
28
- splitTextIntoChunks,
29
- textWithBrackets,
30
- truncateFileName,
31
- ucFirst,
5
+ addIndefiniteArticle,
6
+ buildSingleText,
7
+ camelCaseToDash,
8
+ cn,
9
+ convertToInternationalPhone,
10
+ escapeCSVValue,
11
+ formatPhoneNumber,
12
+ formatReferenceNumber,
13
+ getAlphanumeric,
14
+ getDisplayName,
15
+ getNthString,
16
+ getSearchNames,
17
+ guessFirstName,
18
+ isEmail,
19
+ isInvisibleString,
20
+ isPhone,
21
+ joinReadable,
22
+ makeAddressText,
23
+ passwordStrength,
24
+ regexFromText,
25
+ removeGeneratedTextGarbage,
26
+ shortenToParagraph,
27
+ shortenToSpace,
28
+ splitTextIntoChunks,
29
+ textWithBrackets,
30
+ truncateFileName,
31
+ ucFirst,
32
32
  } from './string.ts';
33
33
 
34
34
  beforeAll(() => {
35
- configI18n();
35
+ configI18n();
36
36
  });
37
37
 
38
38
  describe('cn', () => {
39
- it('joins truthy class names with spaces', () => {
40
- expect(cn('card', false, 'selected', undefined, null, '')).toBe('card selected');
41
- });
39
+ it('joins truthy class names with spaces', () => {
40
+ expect(cn('card', false, 'selected', undefined, null, '')).toBe('card selected');
41
+ });
42
42
  });
43
43
 
44
44
  describe('shortenToSpace', () => {
45
- it('shortens at the last available space before the limit', () => {
46
- expect(shortenToSpace('alpha beta gamma', 12)).toBe('alpha beta...');
47
- });
45
+ it('shortens at the last available space before the limit', () => {
46
+ expect(shortenToSpace('alpha beta gamma', 12)).toBe('alpha beta...');
47
+ });
48
48
 
49
- it('falls back to a hard cut when no spaces exist', () => {
50
- expect(shortenToSpace('alphabetagamma', 5)).toBe('alpha...');
51
- });
49
+ it('falls back to a hard cut when no spaces exist', () => {
50
+ expect(shortenToSpace('alphabetagamma', 5)).toBe('alpha...');
51
+ });
52
52
  });
53
53
 
54
54
  describe('guessFirstName', () => {
55
- it('drops leading articles and returns the first meaningful word', () => {
56
- expect(guessFirstName('the quick brown fox')).toBe('quick');
57
- });
55
+ it('drops leading articles and returns the first meaningful word', () => {
56
+ expect(guessFirstName('the quick brown fox')).toBe('quick');
57
+ });
58
58
 
59
- it('keeps short names instead of stripping the full word as an article suffix', () => {
60
- expect(guessFirstName('An Lee')).toBe('Lee');
61
- });
59
+ it('keeps short names instead of stripping the full word as an article suffix', () => {
60
+ expect(guessFirstName('An Lee')).toBe('Lee');
61
+ });
62
62
  });
63
63
 
64
64
  describe('addIndefiniteArticle', () => {
65
- it('handles silent-h and consonant-sounding vowel exceptions', () => {
66
- expect(addIndefiniteArticle('honest answer')).toBe('an honest answer');
67
- expect(addIndefiniteArticle('user')).toBe('a user');
68
- });
65
+ it('handles silent-h and consonant-sounding vowel exceptions', () => {
66
+ expect(addIndefiniteArticle('honest answer')).toBe('an honest answer');
67
+ expect(addIndefiniteArticle('user')).toBe('a user');
68
+ });
69
69
  });
70
70
 
71
71
  describe('isEmail', () => {
72
- it('accepts trimmed valid emails and rejects malformed values', () => {
73
- expect(isEmail(' hello@example.com ')).toBe(true);
74
- expect(isEmail('hello@example')).toBe(false);
75
- });
72
+ it('accepts trimmed valid emails and rejects malformed values', () => {
73
+ expect(isEmail(' hello@example.com ')).toBe(true);
74
+ expect(isEmail('hello@example')).toBe(false);
75
+ });
76
76
  });
77
77
 
78
78
  describe('convertToInternationalPhone and isPhone', () => {
79
- it('normalizes North American and existing international numbers', () => {
80
- expect(convertToInternationalPhone('(555) 123-4567')).toBe('+15551234567');
81
- expect(convertToInternationalPhone('+44 20 1234 5678')).toBe('+442012345678');
82
- });
83
-
84
- it('rejects invalid phone-like input', () => {
85
- expect(convertToInternationalPhone('05551234567')).toBeNull();
86
- expect(convertToInternationalPhone('555-abc-1234')).toBeNull();
87
- });
88
-
89
- it('supports optional conversion when validating phone numbers', () => {
90
- expect(isPhone('5551234567')).toBe(true);
91
- expect(isPhone('5551234567', true)).toBe(false);
92
- expect(isPhone('+442012345678', true)).toBe(true);
93
- });
79
+ it('normalizes North American and existing international numbers', () => {
80
+ expect(convertToInternationalPhone('(555) 123-4567')).toBe('+15551234567');
81
+ expect(convertToInternationalPhone('+44 20 1234 5678')).toBe('+442012345678');
82
+ });
83
+
84
+ it('rejects invalid phone-like input', () => {
85
+ expect(convertToInternationalPhone('05551234567')).toBeNull();
86
+ expect(convertToInternationalPhone('555-abc-1234')).toBeNull();
87
+ });
88
+
89
+ it('supports optional conversion when validating phone numbers', () => {
90
+ expect(isPhone('5551234567')).toBe(true);
91
+ expect(isPhone('5551234567', true)).toBe(false);
92
+ expect(isPhone('+442012345678', true)).toBe(true);
93
+ });
94
94
  });
95
95
 
96
96
  describe('passwordStrength', () => {
97
- it('reports rule-by-rule password strength details', () => {
98
- expect(passwordStrength('Abcdef1!')).toEqual({
99
- valid: true,
100
- isLongEnough: true,
101
- hasLowercase: true,
102
- hasUppercase: true,
103
- hasDigit: true,
104
- hasSpecial: true,
105
- });
106
-
107
- expect(passwordStrength('abcdefg')).toMatchObject({
108
- valid: false,
109
- isLongEnough: false,
110
- hasLowercase: true,
111
- hasUppercase: false,
112
- hasDigit: false,
113
- hasSpecial: false,
114
- });
115
- });
97
+ it('reports rule-by-rule password strength details', () => {
98
+ expect(passwordStrength('Abcdef1!')).toEqual({
99
+ valid: true,
100
+ isLongEnough: true,
101
+ hasLowercase: true,
102
+ hasUppercase: true,
103
+ hasDigit: true,
104
+ hasSpecial: true,
105
+ });
106
+
107
+ expect(passwordStrength('abcdefg')).toMatchObject({
108
+ valid: false,
109
+ isLongEnough: false,
110
+ hasLowercase: true,
111
+ hasUppercase: false,
112
+ hasDigit: false,
113
+ hasSpecial: false,
114
+ });
115
+ });
116
116
  });
117
117
 
118
118
  describe('getAlphanumeric and getSearchNames', () => {
119
- it('removes punctuation while optionally preserving spaces', () => {
120
- expect(getAlphanumeric('A-B_C!', false)).toBe('ABC');
121
- expect(getAlphanumeric('A-B_C!', true)).toBe('ABC');
122
- });
123
-
124
- it('splits mixed delimiters and keeps case-insensitive unique names', () => {
125
- expect(getSearchNames(['Alice, Bob and alice', 'Carol;\nBob', null])).toEqual([
126
- 'Alice',
127
- 'Bob',
128
- 'Carol',
129
- ]);
130
- });
119
+ it('removes punctuation while optionally preserving spaces', () => {
120
+ expect(getAlphanumeric('A-B_C!', false)).toBe('ABC');
121
+ expect(getAlphanumeric('A-B_C!', true)).toBe('ABC');
122
+ });
123
+
124
+ it('splits mixed delimiters and keeps case-insensitive unique names', () => {
125
+ expect(getSearchNames(['Alice, Bob and alice', 'Carol;\nBob', null])).toEqual(['Alice', 'Bob', 'Carol']);
126
+ });
131
127
  });
132
128
 
133
129
  describe('regexFromText', () => {
134
- it('builds a case-insensitive regex from cleaned words', () => {
135
- const regex = regexFromText('Hello, world!');
130
+ it('builds a case-insensitive regex from cleaned words', () => {
131
+ const regex = regexFromText('Hello, world!');
136
132
 
137
- expect(regex).not.toBeNull();
138
- expect('say hello there'.match(regex!)).toEqual(['hello']);
139
- expect('WORLD tour'.match(regex!)).toEqual(['WORLD']);
140
- });
133
+ expect(regex).not.toBeNull();
134
+ expect('say hello there'.match(regex!)).toEqual(['hello']);
135
+ expect('WORLD tour'.match(regex!)).toEqual(['WORLD']);
136
+ });
141
137
 
142
- it('returns null when no searchable words remain', () => {
143
- expect(regexFromText('a !')).toBeNull();
144
- });
138
+ it('returns null when no searchable words remain', () => {
139
+ expect(regexFromText('a !')).toBeNull();
140
+ });
145
141
  });
146
142
 
147
143
  describe('ucFirst and camelCaseToDash', () => {
148
- it('formats capitalization and dash-separated names', () => {
149
- expect(ucFirst('marketday')).toBe('Marketday');
150
- expect(camelCaseToDash('camelCase2Value')).toBe('camel-case-2-value');
151
- expect(camelCaseToDash('API')).toBe('api');
152
- });
144
+ it('formats capitalization and dash-separated names', () => {
145
+ expect(ucFirst('marketday')).toBe('Marketday');
146
+ expect(camelCaseToDash('camelCase2Value')).toBe('camel-case-2-value');
147
+ expect(camelCaseToDash('API')).toBe('api');
148
+ });
153
149
  });
154
150
 
155
151
  describe('shortenToParagraph', () => {
156
- it('uses paragraph boundaries before falling back to word trimming', () => {
157
- const text = 'First line\nSecond line\nThird line';
152
+ it('uses paragraph boundaries before falling back to word trimming', () => {
153
+ const text = 'First line\nSecond line\nThird line';
158
154
 
159
- expect(shortenToParagraph(text, 18)).toBe('First line');
160
- expect(shortenToParagraph('Alpha beta gamma', 10)).toBe('Alpha...');
161
- });
155
+ expect(shortenToParagraph(text, 18)).toBe('First line');
156
+ expect(shortenToParagraph('Alpha beta gamma', 10)).toBe('Alpha...');
157
+ });
162
158
  });
163
159
 
164
160
  describe('isInvisibleString', () => {
165
- it('detects strings made only from whitespace-like invisible characters', () => {
166
- expect(isInvisibleString('ㅤ️⠀')).toBe(true);
167
- expect(isInvisibleString(' visible ')).toBe(false);
168
- });
161
+ it('detects strings made only from whitespace-like invisible characters', () => {
162
+ expect(isInvisibleString('ㅤ️⠀')).toBe(true);
163
+ expect(isInvisibleString(' visible ')).toBe(false);
164
+ });
169
165
  });
170
166
 
171
167
  describe('buildSingleText', () => {
172
- it('supports feature maps, conditional lines, first-match groups, and blank line collapsing', () => {
173
- expect(
174
- buildSingleText(
175
- [
176
- 'Header',
177
- '',
178
- '',
179
- { advanced: ['Advanced section'] },
180
- [['beta', '!legacy'], ['Beta only']],
181
- [
182
- [['admin'], ['Admin choice']],
183
- [['member'], [' Member choice']],
184
- [['!member'], ['Fallback choice']],
185
- ],
186
- 'Footer',
187
- ],
188
- '\n',
189
- ['advanced', 'beta', 'member'],
190
- ),
191
- ).toBe('Header\n\nAdvanced section\nBeta only\nMember choice\nFooter');
192
- });
168
+ it('renders ternary arrays and nested sections with the selected delimiter', () => {
169
+ for (const preCheck of [true, false]) {
170
+ expect(
171
+ buildSingleText(
172
+ ['Header', '', !preCheck ? ['Summary', '', ['Details', { extra: ['Extra details'] }]] : '', '', 'Footer'],
173
+ '|',
174
+ ['extra'],
175
+ ),
176
+ ).toBe(preCheck ? 'Header||Footer' : 'Header||Summary||Details|Extra details||Footer');
177
+ }
178
+ });
179
+
180
+ it('supports feature maps, conditional lines, first-match groups, and blank line collapsing', () => {
181
+ expect(
182
+ buildSingleText(
183
+ [
184
+ 'Header',
185
+ '',
186
+ '',
187
+ { advanced: ['Advanced section'] },
188
+ [['beta', '!legacy'], ['Beta only']],
189
+ [
190
+ [['admin'], ['Admin choice']],
191
+ [['member'], [' Member choice']],
192
+ [['!member'], ['Fallback choice']],
193
+ ],
194
+ 'Footer',
195
+ ],
196
+ '\n',
197
+ ['advanced', 'beta', 'member'],
198
+ ),
199
+ ).toBe('Header\n\nAdvanced section\nBeta only\nMember choice\nFooter');
200
+ });
193
201
  });
194
202
 
195
203
  describe('joinReadable and textWithBrackets', () => {
196
- it('joins human-readable lists and appends bracket text when present', () => {
197
- expect(joinReadable(['Alpha', 'Beta', 'Gamma'])).toBe('Alpha, Beta and Gamma');
198
- expect(textWithBrackets('Status', ['draft', 'internal'], ['[', ']'])).toBe('Status [draft internal]');
199
- expect(textWithBrackets('', ['draft', 'internal'], ['[', ']'])).toBe('draft internal');
200
- });
204
+ it('joins human-readable lists and appends bracket text when present', () => {
205
+ expect(joinReadable(['Alpha', 'Beta', 'Gamma'])).toBe('Alpha, Beta and Gamma');
206
+ expect(textWithBrackets('Status', ['draft', 'internal'], ['[', ']'])).toBe('Status [draft internal]');
207
+ expect(textWithBrackets('', ['draft', 'internal'], ['[', ']'])).toBe('draft internal');
208
+ });
201
209
  });
202
210
 
203
211
  describe('removeGeneratedTextGarbage and escapeCSVValue', () => {
204
- it('normalizes generated whitespace and escapes CSV-sensitive values', () => {
205
- expect(removeGeneratedTextGarbage('Hello\n\n world\tfrom\r\nAI')).toBe('Hello world from AI');
206
- expect(escapeCSVValue('plain')).toBe('plain');
207
- expect(escapeCSVValue('a,"b"\nc')).toBe('"a,""b""\nc"');
208
- });
212
+ it('normalizes generated whitespace and escapes CSV-sensitive values', () => {
213
+ expect(removeGeneratedTextGarbage('Hello\n\n world\tfrom\r\nAI')).toBe('Hello world from AI');
214
+ expect(escapeCSVValue('plain')).toBe('plain');
215
+ expect(escapeCSVValue('a,"b"\nc')).toBe('"a,""b""\nc"');
216
+ });
209
217
  });
210
218
 
211
219
  describe('truncateFileName', () => {
212
- it('preserves extensions while truncating long file names', () => {
213
- expect(truncateFileName('very-long-document-name.pdf', 12)).toBe('very-....pdf');
214
- expect(truncateFileName('short.txt', 20)).toBe('short.txt');
215
- });
220
+ it('preserves extensions while truncating long file names', () => {
221
+ expect(truncateFileName('very-long-document-name.pdf', 12)).toBe('very-....pdf');
222
+ expect(truncateFileName('short.txt', 20)).toBe('short.txt');
223
+ });
216
224
  });
217
225
 
218
226
  describe('formatPhoneNumber', () => {
219
- it('formats trailing 10 digits into a readable North American phone number', () => {
220
- expect(formatPhoneNumber('+15551234567')).toBe('+1 (555) 123-4567');
221
- expect(formatPhoneNumber('5551234567')).toBe('(555) 123-4567');
222
- expect(formatPhoneNumber('not-a-phone')).toBe('not-a-phone');
223
- });
227
+ it('formats trailing 10 digits into a readable North American phone number', () => {
228
+ expect(formatPhoneNumber('+15551234567')).toBe('+1 (555) 123-4567');
229
+ expect(formatPhoneNumber('5551234567')).toBe('(555) 123-4567');
230
+ expect(formatPhoneNumber('not-a-phone')).toBe('not-a-phone');
231
+ });
224
232
  });
225
233
 
226
234
  describe('splitTextIntoChunks', () => {
227
- it('prefers nearby line breaks when splitting long text', () => {
228
- expect(splitTextIntoChunks('12345\n67890\nabcde', 10, 5)).toEqual([
229
- '12345',
230
- '67890',
231
- 'abcde',
232
- ]);
233
- });
234
-
235
- it('falls back to whitespace boundaries when no line break is nearby', () => {
236
- expect(splitTextIntoChunks('alpha beta gamma delta', 12, 2)).toEqual([
237
- 'alpha beta',
238
- 'gamma delta',
239
- ]);
240
- });
235
+ it('prefers nearby line breaks when splitting long text', () => {
236
+ expect(splitTextIntoChunks('12345\n67890\nabcde', 10, 5)).toEqual(['12345', '67890', 'abcde']);
237
+ });
238
+
239
+ it('falls back to whitespace boundaries when no line break is nearby', () => {
240
+ expect(splitTextIntoChunks('alpha beta gamma delta', 12, 2)).toEqual(['alpha beta', 'gamma delta']);
241
+ });
241
242
  });
242
243
 
243
244
  describe('formatReferenceNumber and getNthString', () => {
244
- it('formats numeric references and ordinal suffixes', () => {
245
- expect(formatReferenceNumber('42')).toBe('#42');
246
- expect(formatReferenceNumber('abc')).toBe('abc');
247
- expect(getNthString(1)).toBe('1st');
248
- expect(getNthString(2)).toBe('2nd');
249
- expect(getNthString(3)).toBe('3rd');
250
- expect(getNthString(11)).toBe('11th');
251
- expect(getNthString(23)).toBe('23rd');
252
- });
245
+ it('formats numeric references and ordinal suffixes', () => {
246
+ expect(formatReferenceNumber('42')).toBe('#42');
247
+ expect(formatReferenceNumber('abc')).toBe('abc');
248
+ expect(getNthString(1)).toBe('1st');
249
+ expect(getNthString(2)).toBe('2nd');
250
+ expect(getNthString(3)).toBe('3rd');
251
+ expect(getNthString(11)).toBe('11th');
252
+ expect(getNthString(23)).toBe('23rd');
253
+ });
253
254
  });
254
255
 
255
256
  describe('makeAddressText and getDisplayName', () => {
256
- it('formats addresses in each supported display mode', () => {
257
- const address = {
258
- line1: '1 Main St',
259
- line2: 'Suite 2',
260
- city: 'Toronto',
261
- state: 'ON',
262
- postalCode: 'A1A 1A1',
263
- country: 'CA',
264
- };
265
-
266
- expect(makeAddressText(address, 'REGION_ONLY')).toBe('Toronto, ON, CA');
267
- expect(makeAddressText(address, 'SINGLE_LINE', true)).toBe(
268
- '1 Main St, Suite 2, Toronto, ON, A1A 1A1, Canada',
269
- );
270
- expect(makeAddressText(address)).toBe(
271
- '1 Main St\nSuite 2\nToronto, ON A1A 1A1\nCA',
272
- );
273
- });
274
-
275
- it('builds a full name and short display name together', () => {
276
- expect(getDisplayName('John', 'Smith')).toEqual({
277
- fullName: 'John Smith',
278
- displayName: 'John',
279
- });
280
- });
257
+ it('formats addresses in each supported display mode', () => {
258
+ const address = {
259
+ line1: '1 Main St',
260
+ line2: 'Suite 2',
261
+ city: 'Toronto',
262
+ state: 'ON',
263
+ postalCode: 'A1A 1A1',
264
+ country: 'CA',
265
+ };
266
+
267
+ expect(makeAddressText(address, 'REGION_ONLY')).toBe('Toronto, ON, CA');
268
+ expect(makeAddressText(address, 'SINGLE_LINE', true)).toBe('1 Main St, Suite 2, Toronto, ON, A1A 1A1, Canada');
269
+ expect(makeAddressText(address)).toBe('1 Main St\nSuite 2\nToronto, ON A1A 1A1\nCA');
270
+ });
271
+
272
+ it('builds a full name and short display name together', () => {
273
+ expect(getDisplayName('John', 'Smith')).toEqual({
274
+ fullName: 'John Smith',
275
+ displayName: 'John',
276
+ });
277
+ });
281
278
  });