gristlabs_grist-core/test/common/DocActions.ts
Jarosław Sadziński a52d56f613 (core) Moving client and common tests to core
Summary:
- Moved /test/client and /test/common to core.
- Moved two files (CircularArray and RecentItems) from app/common to core/app/common.
- Moved resetOrg test to gen-server.
- `testrun.sh` is now invoking common and client test from core.
- Added missing packages to core's package.json (and revealed underscore as it is used in the main app).
- Removed Coord.js as it is not used anywhere.

Test Plan: Existing tests

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3590
2022-08-23 19:20:10 +02:00

34 lines
1.3 KiB
TypeScript

import {fromTableDataAction, TableDataAction, toTableDataAction} from 'app/common/DocActions';
import {assert} from 'chai';
describe('DocActions', function() {
it('should convert correctly with toTableDataAction', () => {
const colValues = {id: [2, 4, 6], foo: ["a", "b", "c"], bar: [false, "y", null]};
assert.deepEqual(toTableDataAction("Hello", colValues),
['TableData', "Hello", [2, 4, 6],
{ foo: ["a", "b", "c"], bar: [false, "y", null] }]);
// Make sure colValues that was passed-in didn't get changed.
assert.deepEqual(colValues,
{id: [2, 4, 6], foo: ["a", "b", "c"], bar: [false, "y", null]});
assert.deepEqual(toTableDataAction("Foo", {id: []}), ['TableData', "Foo", [], {}]);
});
it('should convert correctly with fromTableDataAction', () => {
const tableData: TableDataAction = ['TableData', "Hello", [2, 4, 6],
{ foo: ["a", "b", "c"], bar: [false, "y", null] }];
assert.deepEqual(fromTableDataAction(tableData),
{id: [2, 4, 6], foo: ["a", "b", "c"], bar: [false, "y", null]});
// Make sure tableData itself is unchanged.
assert.deepEqual(tableData, ['TableData', "Hello", [2, 4, 6],
{ foo: ["a", "b", "c"], bar: [false, "y", null] }]);
assert.deepEqual(fromTableDataAction(['TableData', "Foo", [], {}]), {id: []});
});
});