-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ #2 Vertical/Horizontal/Wrapping control
- Loading branch information
1 parent
3b7b795
commit efb040f
Showing
17 changed files
with
13,437 additions
and
6,811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,7 @@ | |
|
||
# msbuild output directories | ||
/bin | ||
/obj | ||
/obj | ||
|
||
# Jest coverage results | ||
**/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"name": "vscode-jest-tests", | ||
"request": "launch", | ||
"args": ["${fileBasename}", "--runInBand", "--code-coverage=false" ], | ||
"cwd": "${workspaceFolder}", | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"smartStep": true, | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"cSpell.words": [ | ||
"powerdnd", | ||
"Picklist", | ||
"powerdnd", | ||
"sonarjs", | ||
"sortablejs", | ||
"Unchoose" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* istanbul ignore file */ | ||
|
||
export class MockContext<T> implements ComponentFramework.Context<T> { | ||
constructor(parameters: T) { | ||
this.parameters = parameters; | ||
this.mode = { | ||
allocatedHeight: -1, | ||
allocatedWidth: -1, | ||
isControlDisabled: false, | ||
isVisible: true, | ||
label: '', | ||
setControlState: jest.fn(), | ||
setFullScreen: jest.fn(), | ||
trackContainerResize: jest.fn(), | ||
}; | ||
this.client = { | ||
disableScroll: false, | ||
getClient: jest.fn(), | ||
getFormFactor: jest.fn(), | ||
isOffline: jest.fn(), | ||
}; | ||
|
||
// Canvas apps currently assigns a positive tab-index | ||
// so we must use this property to assign a positive tab-index also | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(this as any).accessibility = { assignedTabIndex: 0 }; | ||
} | ||
client: ComponentFramework.Client; | ||
device: ComponentFramework.Device; | ||
factory: ComponentFramework.Factory; | ||
formatting: ComponentFramework.Formatting; | ||
mode: ComponentFramework.Mode; | ||
navigation: ComponentFramework.Navigation; | ||
resources: ComponentFramework.Resources; | ||
userSettings: ComponentFramework.UserSettings; | ||
utils: ComponentFramework.Utility; | ||
webAPI: ComponentFramework.WebApi; | ||
parameters: T; | ||
updatedProperties: string[] = []; | ||
} | ||
|
||
export class MockState implements ComponentFramework.Dictionary {} | ||
|
||
export class MockStringProperty implements ComponentFramework.PropertyTypes.StringProperty { | ||
constructor(raw?: string | null, formatted?: string | undefined) { | ||
this.raw = raw ?? null; | ||
this.formatted = formatted; | ||
} | ||
raw: string | null; | ||
attributes?: ComponentFramework.PropertyHelper.FieldPropertyMetadata.StringMetadata | undefined; | ||
error: boolean; | ||
errorMessage: string; | ||
formatted?: string | undefined; | ||
security?: ComponentFramework.PropertyHelper.SecurityValues | undefined; | ||
type: string; | ||
} | ||
|
||
export class MockWholeNumberProperty implements ComponentFramework.PropertyTypes.WholeNumberProperty { | ||
constructor(raw?: number | null, formatted?: string | undefined) { | ||
this.raw = raw ?? null; | ||
this.formatted = formatted; | ||
} | ||
attributes?: ComponentFramework.PropertyHelper.FieldPropertyMetadata.WholeNumberMetadata | undefined; | ||
raw: number | null; | ||
error: boolean; | ||
errorMessage: string; | ||
formatted?: string | undefined; | ||
security?: ComponentFramework.PropertyHelper.SecurityValues | undefined; | ||
type: string; | ||
} | ||
|
||
export class MockDecimalProperty implements ComponentFramework.PropertyTypes.DecimalNumberProperty { | ||
constructor(raw?: number | null, formatted?: string | undefined) { | ||
this.raw = raw ?? null; | ||
this.formatted = formatted; | ||
} | ||
attributes?: ComponentFramework.PropertyHelper.FieldPropertyMetadata.DecimalNumberMetadata | undefined; | ||
raw: number | null; | ||
error: boolean; | ||
errorMessage: string; | ||
formatted?: string | undefined; | ||
security?: ComponentFramework.PropertyHelper.SecurityValues | undefined; | ||
type: string; | ||
} | ||
|
||
export class MockEnumProperty<T> implements ComponentFramework.PropertyTypes.EnumProperty<T> { | ||
constructor(raw?: T, type?: string) { | ||
if (raw) this.raw = raw; | ||
if (type) this.type = type; | ||
} | ||
type: string; | ||
raw: T; | ||
} | ||
|
||
export class MockTwoOptionsProperty implements ComponentFramework.PropertyTypes.TwoOptionsProperty { | ||
constructor(raw?: boolean) { | ||
if (raw) this.raw = raw; | ||
} | ||
raw: boolean; | ||
attributes?: ComponentFramework.PropertyHelper.FieldPropertyMetadata.TwoOptionMetadata | undefined; | ||
error: boolean; | ||
errorMessage: string; | ||
formatted?: string | undefined; | ||
security?: ComponentFramework.PropertyHelper.SecurityValues | undefined; | ||
type: string; | ||
} |
108 changes: 108 additions & 0 deletions
108
code-component/PowerDragDrop/__mocks__/mock-datasets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* istanbul ignore file */ | ||
|
||
export class MockDataSet implements ComponentFramework.PropertyTypes.DataSet { | ||
private rows: MockEntityRecord[] = []; | ||
constructor(rows: MockEntityRecord[]) { | ||
this.rows = rows; | ||
this.records = {}; | ||
rows.forEach((r) => (this.records[r.id] = r)); | ||
this.sortedRecordIds = rows.map((r) => r.id); | ||
this.paging = { | ||
setPageSize: jest.fn(), | ||
totalResultCount: 0, | ||
firstPageNumber: 0, | ||
hasNextPage: false, | ||
hasPreviousPage: false, | ||
lastPageNumber: 0, | ||
loadExactPage: jest.fn(), | ||
loadNextPage: jest.fn(), | ||
loadPreviousPage: jest.fn(), | ||
pageSize: 0, | ||
reset: jest.fn(), | ||
}; | ||
} | ||
addColumn = jest.fn(); | ||
columns: ComponentFramework.PropertyHelper.DataSetApi.Column[] = []; | ||
error: boolean; | ||
errorMessage: string; | ||
filtering: ComponentFramework.PropertyHelper.DataSetApi.Filtering; | ||
linking: ComponentFramework.PropertyHelper.DataSetApi.Linking; | ||
loading: boolean; | ||
paging: ComponentFramework.PropertyHelper.DataSetApi.Paging; | ||
records: { [id: string]: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord }; | ||
sortedRecordIds: string[]; | ||
sorting: ComponentFramework.PropertyHelper.DataSetApi.SortStatus[]; | ||
clearSelectedRecordIds = jest.fn(); | ||
getSelectedRecordIds = jest.fn(); | ||
getTargetEntityType = jest.fn(); | ||
getTitle = jest.fn(); | ||
getViewId = jest.fn(); | ||
openDatasetItem = jest.fn(); | ||
refresh = jest.fn(); | ||
setSelectedRecordIds = jest.fn(); | ||
} | ||
|
||
export class MockColumn implements ComponentFramework.PropertyHelper.DataSetApi.Column { | ||
name: string; | ||
displayName: string; | ||
dataType!: string; | ||
alias!: string; | ||
order!: number; | ||
visualSizeFactor!: number; | ||
isHidden?: boolean | undefined; | ||
isPrimary?: boolean | undefined; | ||
disableSorting?: boolean | undefined; | ||
constructor(name: string, displayName: string) { | ||
this.name = name; | ||
this.displayName = displayName; | ||
} | ||
} | ||
|
||
type valueType = | ||
| string | ||
| number | ||
| boolean | ||
| Date | ||
| number[] | ||
| ComponentFramework.EntityReference | ||
| ComponentFramework.EntityReference[] | ||
| ComponentFramework.LookupValue | ||
| ComponentFramework.LookupValue[]; | ||
|
||
export class MockEntityRecord implements ComponentFramework.PropertyHelper.DataSetApi.EntityRecord { | ||
values: Record<string, valueType>; | ||
id: string; | ||
constructor(id: string, values: Record<string, valueType>) { | ||
this.values = values; | ||
this.id = id; | ||
} | ||
getFormattedValue(columnName: string): string { | ||
return this.values[columnName] as string; | ||
} | ||
getRecordId(): string { | ||
return this.id; | ||
} | ||
getValue(columnName: string): valueType { | ||
return this.values[columnName]; | ||
} | ||
getNamedReference = jest.fn(); | ||
} | ||
|
||
export function getData( | ||
records: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord[], | ||
): { | ||
sortedRecordIds: string[]; | ||
records: Record<string, ComponentFramework.PropertyHelper.DataSetApi.EntityRecord>; | ||
} { | ||
const sortedRecordIds: string[] = []; | ||
const recordsOut: Record<string, ComponentFramework.PropertyHelper.DataSetApi.EntityRecord> = {}; | ||
|
||
for (const r of records) { | ||
sortedRecordIds.push(r.getRecordId()); | ||
recordsOut[r.getRecordId()] = r; | ||
} | ||
return { | ||
sortedRecordIds: sortedRecordIds, | ||
records: recordsOut, | ||
}; | ||
} |
Oops, something went wrong.