2021-03-24 19:25:38 +00:00
|
|
|
import derivedProperty from "./derived";
|
|
|
|
|
import moment from "moment";
|
|
|
|
|
import _ from "lodash";
|
|
|
|
|
describe("Validates Derived Properties", () => {
|
|
|
|
|
it("validates columns generation function for empty values", () => {
|
|
|
|
|
const { getTableColumns } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [],
|
|
|
|
|
sortedColumn: undefined,
|
|
|
|
|
columnOrder: ["id", "another"],
|
|
|
|
|
};
|
|
|
|
|
const expected = [];
|
|
|
|
|
|
|
|
|
|
let result = getTableColumns(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
|
|
|
|
|
let result = getTableColumns({}, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("validates columns generation function for valid values", () => {
|
|
|
|
|
const { getTableColumns } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
};
|
|
|
|
|
const expected = [
|
|
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "name",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let result = getTableColumns(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
it("generated columns does not modify primary columns", () => {
|
|
|
|
|
const { getTableColumns } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {
|
|
|
|
|
id: {
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
const expected = [
|
|
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let result = getTableColumns(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("generated columns removes unexpected columns in primary columns", () => {
|
|
|
|
|
const { getTableColumns } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {
|
|
|
|
|
id: {
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Extra1", "Extra2"],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
const expected = [
|
|
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let result = getTableColumns(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
it("generated columns does not remove derived columns in primary columns", () => {
|
|
|
|
|
const { getTableColumns } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {
|
|
|
|
|
id: {
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
const expected = [
|
|
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let result = getTableColumns(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("validates generated filtered table data", () => {
|
|
|
|
|
const { getFilteredTableData } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {
|
|
|
|
|
id: {
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-04-02 08:18:30 +00:00
|
|
|
tableColumns: [
|
2021-03-24 19:25:38 +00:00
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [123, 234],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const expected = [
|
2021-03-25 19:48:40 +00:00
|
|
|
{ id: 234, name: "Jane Doe", extra: "Extra2", __originalIndex__: 1 },
|
|
|
|
|
{ id: 123, name: "John Doe", extra: "Extra1", __originalIndex__: 0 },
|
2021-03-24 19:25:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let result = getFilteredTableData(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("validates generated filtered table data for empty values", () => {
|
|
|
|
|
const { getFilteredTableData } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {},
|
|
|
|
|
columns: [],
|
|
|
|
|
};
|
|
|
|
|
const expected = [];
|
|
|
|
|
|
|
|
|
|
let result = getFilteredTableData(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("validates generated filtered table data to be sorted correctly based on column type", () => {
|
|
|
|
|
const { getFilteredTableData } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 1234, name: "Jim Doe" },
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {
|
|
|
|
|
id: {
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "number",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [1234, 123, 234],
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Jim Doe", "John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["", "Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-04-02 08:18:30 +00:00
|
|
|
tableColumns: [
|
2021-03-24 19:25:38 +00:00
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Jim Doe", "John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "number",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [1234, 123, 234],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["", "Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const expected = [
|
2021-03-25 19:48:40 +00:00
|
|
|
{ id: 1234, name: "Jim Doe", extra: "", __originalIndex__: 0 },
|
|
|
|
|
{ id: 234, name: "Jane Doe", extra: "Extra2", __originalIndex__: 2 },
|
|
|
|
|
{ id: 123, name: "John Doe", extra: "Extra1", __originalIndex__: 1 },
|
2021-03-24 19:25:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let result = getFilteredTableData(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
2021-06-18 12:04:34 +00:00
|
|
|
|
|
|
|
|
it("validates generated filtered table data to be filtered correctly in empty comparison", () => {
|
|
|
|
|
const { getFilteredTableData } = derivedProperty;
|
|
|
|
|
const input = {
|
|
|
|
|
sanitizedTableData: [
|
|
|
|
|
{ id: 1234, name: "Jim Doe" },
|
|
|
|
|
{ id: 123, name: "John Doe" },
|
|
|
|
|
{ id: 234, name: "Jane Doe" },
|
|
|
|
|
],
|
|
|
|
|
filters: [
|
|
|
|
|
{
|
|
|
|
|
condition: "empty",
|
|
|
|
|
column: "id",
|
|
|
|
|
value: "",
|
|
|
|
|
operator: "OR",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
sortedColumn: { column: "id", asc: false },
|
|
|
|
|
columnOrder: ["name", "id"],
|
|
|
|
|
primaryColumns: {
|
|
|
|
|
id: {
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "number",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [1234, 123, 234],
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Jim Doe", "John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["", "Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
tableColumns: [
|
|
|
|
|
{
|
|
|
|
|
index: 0,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "name",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "awesome",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["Jim Doe", "John Doe", "Jane Doe"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 1,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "id",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "number",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isDerived: false,
|
|
|
|
|
label: "id",
|
|
|
|
|
isAscOrder: false,
|
|
|
|
|
computedValue: [1234, 123, 234],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
index: 2,
|
|
|
|
|
width: 150,
|
|
|
|
|
id: "extra",
|
|
|
|
|
horizontalAlignment: "LEFT",
|
|
|
|
|
verticalAlignment: "CENTER",
|
|
|
|
|
columnType: "text",
|
|
|
|
|
textColor: "#231F20",
|
|
|
|
|
textSize: "PARAGRAPH",
|
|
|
|
|
fontStyle: "REGULAR",
|
|
|
|
|
enableFilter: true,
|
|
|
|
|
enableSort: true,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "extra",
|
|
|
|
|
isAscOrder: undefined,
|
|
|
|
|
computedValue: ["", "Extra1", "Extra2"],
|
|
|
|
|
isDerived: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const expected = [];
|
|
|
|
|
|
|
|
|
|
let result = getFilteredTableData(input, moment, _);
|
|
|
|
|
expect(result).toStrictEqual(expected);
|
|
|
|
|
});
|
2021-03-24 19:25:38 +00:00
|
|
|
});
|