Skip to content

Commit a8bbdb0

Browse files
committed
jest
1 parent ffe0849 commit a8bbdb0

2 files changed

Lines changed: 88 additions & 17 deletions

File tree

packages/components/src/internal/components/editable/models.test.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,12 +1170,18 @@ describe('EditorModel', () => {
11701170
raw: 123,
11711171
},
11721172
]),
1173+
[genCellKey(sampleColFk, 2)]: List<ValueDescriptor>([
1174+
{
1175+
display: 'Sample,321',
1176+
raw: 321,
1177+
},
1178+
]),
11731179
});
11741180
const editorModel = modifyEm({
11751181
cellValues: basicEditorModel.cellValues.merge(cellValues),
11761182
columnMap: basicEditorModel.columnMap.set(sampleColFk, sampleColumn),
11771183
orderedColumns: basicEditorModel.orderedColumns.push(sampleColFk),
1178-
rowCount: 2,
1184+
rowCount: 3,
11791185
});
11801186
expect(editorModel.getRowValue(1, false).get('SampleID')).toBe(123);
11811187
expect(editorModel.getRowValue(1, false).get('SampleID/Name')).toBe(undefined);
@@ -1184,6 +1190,50 @@ describe('EditorModel', () => {
11841190
expect(editorModel.getRowValue(1, false, () => true).get('SampleID')).toBe(123);
11851191
expect(editorModel.getRowValue(1, false, () => true).get('SampleID/Name')).toBe('Sample-123');
11861192
});
1193+
test('include string list lookup display value', () => {
1194+
const lookColumn = new QueryColumn({
1195+
caption: 'List Look',
1196+
fieldKey: 'ListLook',
1197+
fieldKeyArray: ['ListLook'],
1198+
jsonType: 'string',
1199+
name: 'ListLook',
1200+
shownInInsertView: true,
1201+
shownInUpdateView: true,
1202+
required: true,
1203+
userEditable: true,
1204+
lookup: {
1205+
schemaName: 'lists',
1206+
queryName: 'Location',
1207+
displayColumn: 'Path',
1208+
keyColumn: 'Path',
1209+
},
1210+
});
1211+
const colFk = lookColumn.fieldKey.toLowerCase();
1212+
const cellValues = fromJS({
1213+
[genCellKey(colFk, 0)]: List<ValueDescriptor>([{ display: undefined, raw: undefined }]),
1214+
[genCellKey(colFk, 1)]: List<ValueDescriptor>([
1215+
{
1216+
display: 'Building 123',
1217+
raw: 'Building 123',
1218+
},
1219+
]),
1220+
[genCellKey(colFk, 2)]: List<ValueDescriptor>([
1221+
{
1222+
display: 'Building, 321',
1223+
raw: 'Building, 321',
1224+
},
1225+
]),
1226+
});
1227+
const editorModel = modifyEm({
1228+
cellValues: basicEditorModel.cellValues.merge(cellValues),
1229+
columnMap: basicEditorModel.columnMap.set(colFk, lookColumn),
1230+
orderedColumns: basicEditorModel.orderedColumns.push(colFk),
1231+
rowCount: 3,
1232+
});
1233+
expect(editorModel.getRowValue(0).get('ListLook')).toBe(undefined);
1234+
expect(editorModel.getRowValue(1).get('ListLook')).toBe('Building 123');
1235+
expect(editorModel.getRowValue(2).get('ListLook')).toBe('Building, 321');
1236+
});
11871237
});
11881238

11891239
describe('utils', () => {

packages/components/src/internal/query/api.test.ts

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,26 @@ describe('api', () => {
138138
});
139139

140140
describe('quoteValueColumnWithDelimiters', () => {
141-
const results: ISelectRowsResult = {
142-
key: 'test',
143-
models: {
144-
test: {
145-
1: { Name: { value: 'one', url: 'http://one/test', randomProperty: 123 } },
146-
2: { Name: { value: 'with, comma', url: 'http://with, comma/test' } },
147-
4: { Name: { value: 'with "quotes", and comma' } },
148-
3: { NoName: { value: 'nonesuch', url: 'http://with, comma/test' } },
149-
5: { Name: { value: ', comma first', displayValue: ',', url: 'http://with, comma/test' } },
141+
function getResults(): ISelectRowsResult {
142+
return {
143+
key: 'test',
144+
models: {
145+
test: {
146+
1: { Name: { value: 'one', url: 'http://one/test', randomProperty: 123 } },
147+
2: { Name: { value: 'with, comma', url: 'http://with, comma/test' } },
148+
4: { Name: { value: 'with "quotes", and comma' } },
149+
3: { NoName: { value: 'nonesuch', url: 'http://with, comma/test' } },
150+
5: { Name: { value: ', comma first', displayValue: ',', url: 'http://with, comma/test' } },
151+
},
150152
},
151-
},
152-
orderedModels: List([1, 2, 3, 4, 5]),
153-
queries: {},
154-
rowCount: 5,
155-
};
156-
test('encode', () => {
157-
expect(quoteValueColumnWithDelimiters(results, 'Name', ',')).toStrictEqual({
153+
orderedModels: List([1, 2, 3, 4, 5]),
154+
queries: {},
155+
rowCount: 5,
156+
};
157+
}
158+
159+
test('encode (multiple=true by default)', () => {
160+
expect(quoteValueColumnWithDelimiters(getResults(), 'Name', ',')).toStrictEqual({
158161
key: 'test',
159162
models: {
160163
test: {
@@ -181,6 +184,24 @@ describe('api', () => {
181184
rowCount: 5,
182185
});
183186
});
187+
188+
test('no encode when multiple=false', () => {
189+
expect(quoteValueColumnWithDelimiters(getResults(), 'Name', ',', false)).toStrictEqual({
190+
key: 'test',
191+
models: {
192+
test: {
193+
1: { Name: { value: 'one', url: 'http://one/test', displayValue: 'one', randomProperty: 123 } },
194+
2: { Name: { value: 'with, comma', url: 'http://with, comma/test', displayValue: 'with, comma' } },
195+
4: { Name: { value: 'with "quotes", and comma', displayValue: 'with "quotes", and comma' } },
196+
3: { NoName: { value: 'nonesuch', url: 'http://with, comma/test' } },
197+
5: { Name: { value: ', comma first', displayValue: ',', url: 'http://with, comma/test' } },
198+
},
199+
},
200+
orderedModels: List([1, 2, 3, 4, 5]),
201+
queries: {},
202+
rowCount: 5,
203+
});
204+
});
184205
});
185206

186207
test('splitRowsByContainer', () => {

0 commit comments

Comments
 (0)