@kineticdata/react 6.0.1 → 6.0.3

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 (258) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/lib/apis/agent/adapters.js +2 -3
  3. package/lib/apis/agent/bridges.js +7 -13
  4. package/lib/apis/agent/handlers.js +7 -13
  5. package/lib/apis/core/activity.js +2 -3
  6. package/lib/apis/core/attributeDefinitions.js +6 -11
  7. package/lib/apis/core/attributeDefinitions.test.js +201 -213
  8. package/lib/apis/core/authentication.js +74 -84
  9. package/lib/apis/core/backgroundJobs.js +5 -9
  10. package/lib/apis/core/bridgeModelAttributeMappings.js +5 -10
  11. package/lib/apis/core/bridgeModelAttributes.js +6 -11
  12. package/lib/apis/core/bridgeModelMappings.js +5 -10
  13. package/lib/apis/core/bridgeModelQualificationMappings.js +5 -10
  14. package/lib/apis/core/bridgeModelQualifications.js +5 -10
  15. package/lib/apis/core/bridgeModels.js +7 -13
  16. package/lib/apis/core/bridgeModels.test.js +313 -333
  17. package/lib/apis/core/bridgedresources.js +7 -13
  18. package/lib/apis/core/categories.js +6 -11
  19. package/lib/apis/core/fileResources.js +5 -10
  20. package/lib/apis/core/filestores.js +5 -10
  21. package/lib/apis/core/formTypes.js +6 -11
  22. package/lib/apis/core/forms.js +6 -11
  23. package/lib/apis/core/forms.test.js +201 -213
  24. package/lib/apis/core/kapps.js +6 -11
  25. package/lib/apis/core/kapps.test.js +122 -130
  26. package/lib/apis/core/logs.js +3 -5
  27. package/lib/apis/core/memberships.js +3 -5
  28. package/lib/apis/core/meta.js +6 -11
  29. package/lib/apis/core/notices.js +2 -3
  30. package/lib/apis/core/oauthClients.js +6 -11
  31. package/lib/apis/core/platformComponents.js +10 -19
  32. package/lib/apis/core/platformItems.js +2 -3
  33. package/lib/apis/core/profile.js +3 -5
  34. package/lib/apis/core/securityPolicyDefinitions.js +6 -11
  35. package/lib/apis/core/securityPolicyDefinitions.test.js +254 -268
  36. package/lib/apis/core/space.js +3 -5
  37. package/lib/apis/core/space.test.js +106 -114
  38. package/lib/apis/core/submissions.js +19 -35
  39. package/lib/apis/core/teams.js +6 -11
  40. package/lib/apis/core/translations.js +18 -35
  41. package/lib/apis/core/translations.test.js +1343 -1437
  42. package/lib/apis/core/users.js +6 -11
  43. package/lib/apis/core/version.js +2 -3
  44. package/lib/apis/core/webApis.js +5 -10
  45. package/lib/apis/core/webhooks.js +6 -11
  46. package/lib/apis/core/webhooks.test.js +243 -257
  47. package/lib/apis/core/webhooksJobs.js +3 -5
  48. package/lib/apis/core/workflows.js +7 -13
  49. package/lib/apis/http.js +16 -31
  50. package/lib/apis/system/index.js +46 -91
  51. package/lib/apis/task/index.js +60 -119
  52. package/lib/components/agent/bridge/BridgeForm.js +1 -2
  53. package/lib/components/agent/bridge/BridgeTable.js +1 -2
  54. package/lib/components/agent/filestore/FilestoreForm.js +1 -2
  55. package/lib/components/agent/filestore/FilestoreTable.js +1 -2
  56. package/lib/components/agent/handler/AgentHandlerForm.js +1 -2
  57. package/lib/components/agent/handler/AgentHandlerTable.js +1 -2
  58. package/lib/components/common/AttributeSelect.js +2 -3
  59. package/lib/components/common/BridgeSelect.js +16 -17
  60. package/lib/components/common/ComponentConfigContext.js +1 -2
  61. package/lib/components/common/ContentEditable.js +23 -3
  62. package/lib/components/common/FormSelect.js +16 -17
  63. package/lib/components/common/NodeSelect.js +2 -3
  64. package/lib/components/common/Scroller.js +2 -3
  65. package/lib/components/common/StaticSelect.js +14 -15
  66. package/lib/components/common/TableInput.js +276 -63
  67. package/lib/components/common/TeamSelect.js +16 -17
  68. package/lib/components/common/ToastContainer.js +7 -12
  69. package/lib/components/common/Typeahead.js +15 -2
  70. package/lib/components/common/UserSelect.js +16 -17
  71. package/lib/components/common/authentication/AuthInterceptor.js +2 -3
  72. package/lib/components/common/authentication/AuthInterceptor.test.js +141 -153
  73. package/lib/components/common/authentication/AuthenticationContainer.js +332 -343
  74. package/lib/components/common/authentication/RequestInterceptor.js +2 -10
  75. package/lib/components/common/code_input/CodeInput.js +4 -9
  76. package/lib/components/common/code_input/draftHelpers.js +20 -37
  77. package/lib/components/common/code_input/languageHelpers.js +6 -12
  78. package/lib/components/common/code_input/languageHelpers.test.js +10 -8
  79. package/lib/components/common/defaults/Toast.js +1 -2
  80. package/lib/components/common/defaults/index.js +2 -3
  81. package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +1 -2
  82. package/lib/components/core/attribute_definition/AttributeDefinitionTable.js +1 -2
  83. package/lib/components/core/bridge_model/BridgeModelForm.js +52 -55
  84. package/lib/components/core/bridge_model/BridgeModelTable.js +1 -2
  85. package/lib/components/core/bridge_model_attribute/BridgeModelAttributeForm.js +1 -2
  86. package/lib/components/core/bridge_model_attribute/BridgeModelAttributeTable.js +1 -2
  87. package/lib/components/core/bridge_model_qualification/BridgeModelQualificationForm.js +1 -2
  88. package/lib/components/core/bridge_model_qualification/BridgeModelQualificationTable.js +1 -2
  89. package/lib/components/core/category/CategoryForm.js +1 -2
  90. package/lib/components/core/category/CategoryTable.js +1 -2
  91. package/lib/components/core/core_form/CoreForm.js +11 -22
  92. package/lib/components/core/core_form/defaults/index.js +11 -19
  93. package/lib/components/core/core_form/globals.js +3 -5
  94. package/lib/components/core/field_definition/FieldDefinitionForm.js +1 -2
  95. package/lib/components/core/field_definition/FieldDefinitionTable.js +2 -4
  96. package/lib/components/core/file_resource/FileResourceForm.js +1 -2
  97. package/lib/components/core/file_resource/FileResourceTable.js +1 -2
  98. package/lib/components/core/form/FormForm.js +4 -4
  99. package/lib/components/core/form/FormTable.js +1 -2
  100. package/lib/components/core/form_type/FormTypeForm.js +1 -2
  101. package/lib/components/core/form_type/FormTypeTable.js +1 -2
  102. package/lib/components/core/i18n/I18n.js +2 -4
  103. package/lib/components/core/i18n/I18nContext.js +1 -2
  104. package/lib/components/core/i18n/I18nProvider.js +2 -3
  105. package/lib/components/core/i18n/Moment.js +10 -9
  106. package/lib/components/core/index_definition/IndexDefinitionForm.js +1 -2
  107. package/lib/components/core/index_definition/IndexDefinitionTable.js +1 -2
  108. package/lib/components/core/index_job/IndexJobTable.js +1 -2
  109. package/lib/components/core/kapp/KappForm.js +1 -2
  110. package/lib/components/core/kapp/KappTable.js +1 -2
  111. package/lib/components/core/log/LogTable.js +2 -4
  112. package/lib/components/core/oauth_client/OAuthClientForm.js +1 -2
  113. package/lib/components/core/oauth_client/OAuthClientTable.js +1 -2
  114. package/lib/components/core/platform_component/AgentComponentForm.js +1 -2
  115. package/lib/components/core/platform_component/AgentComponentTable.js +1 -2
  116. package/lib/components/core/platform_component/TaskComponentForm.js +1 -2
  117. package/lib/components/core/profile/ProfileForm.js +1 -2
  118. package/lib/components/core/security_definition/SecurityDefinitionForm.js +3 -6
  119. package/lib/components/core/security_definition/SecurityDefinitionTable.js +1 -2
  120. package/lib/components/core/space/SpaceForm.js +1 -2
  121. package/lib/components/core/submission/DatastoreSubmissionFilters.js +3 -5
  122. package/lib/components/core/submission/DatastoreSubmissionTable.js +2 -4
  123. package/lib/components/core/submission/FormSubmissionFilters.js +4 -7
  124. package/lib/components/core/submission/FormSubmissionTable.js +2 -4
  125. package/lib/components/core/submission/KappSubmissionTable.js +2 -4
  126. package/lib/components/core/submission/SubmissionForm.js +1 -2
  127. package/lib/components/core/submission/SubmissionTable.js +2 -3
  128. package/lib/components/core/submission/helpers.js +4 -7
  129. package/lib/components/core/team/TeamForm.js +1 -2
  130. package/lib/components/core/team/TeamTable.js +1 -2
  131. package/lib/components/core/translation/ContextForm.js +1 -2
  132. package/lib/components/core/translation/ContextTable.js +1 -2
  133. package/lib/components/core/translation/EntryForm.js +1 -2
  134. package/lib/components/core/translation/EntryTable.js +1 -2
  135. package/lib/components/core/translation/LocaleForm.js +1 -2
  136. package/lib/components/core/translation/LocaleTable.js +1 -2
  137. package/lib/components/core/user/UserForm.js +1 -2
  138. package/lib/components/core/user/UserTable.js +1 -2
  139. package/lib/components/core/webapi/WebApiForm.js +97 -101
  140. package/lib/components/core/webapi/WebApiTable.js +1 -2
  141. package/lib/components/core/webhook/WebhookForm.js +1 -2
  142. package/lib/components/core/webhook/WebhookTable.js +1 -2
  143. package/lib/components/core/webhook_job/WebhookJobTable.js +1 -2
  144. package/lib/components/form/Form.helpers.js +10 -19
  145. package/lib/components/form/Form.js +312 -355
  146. package/lib/components/form/Form.models.js +6 -11
  147. package/lib/components/form/FormState.js +3 -3
  148. package/lib/components/form/KitchenSinkForm.js +23 -3
  149. package/lib/components/form/SimpleForm.helpers.js +262 -0
  150. package/lib/components/form/SimpleForm.js +462 -0
  151. package/lib/components/form/SimpleForm.models.js +62 -0
  152. package/lib/components/form/defaults/AttributesField.js +3 -4
  153. package/lib/components/form/defaults/CheckboxField.js +2 -3
  154. package/lib/components/form/defaults/CodeField.js +2 -3
  155. package/lib/components/form/defaults/FormButtons.js +2 -3
  156. package/lib/components/form/defaults/FormError.js +2 -3
  157. package/lib/components/form/defaults/FormField.js +2 -3
  158. package/lib/components/form/defaults/FormLayout.js +2 -3
  159. package/lib/components/form/defaults/FormMultiField.js +2 -3
  160. package/lib/components/form/defaults/PasswordField.js +2 -3
  161. package/lib/components/form/defaults/RadioField.js +2 -3
  162. package/lib/components/form/defaults/SampleTeamsRolesFIeld.js +2 -3
  163. package/lib/components/form/defaults/SelectField.js +2 -3
  164. package/lib/components/form/defaults/SelectMultiField.js +2 -3
  165. package/lib/components/form/defaults/TableField.js +2 -3
  166. package/lib/components/form/defaults/TeamField.js +2 -3
  167. package/lib/components/form/defaults/TeamMultiField.js +2 -3
  168. package/lib/components/form/defaults/TextField.js +2 -3
  169. package/lib/components/form/defaults/TextMultiField.js +2 -3
  170. package/lib/components/form/defaults/UserField.js +2 -3
  171. package/lib/components/form/defaults/UserMultiField.js +2 -3
  172. package/lib/components/form/defaults/index.js +2 -3
  173. package/lib/components/form/tests/Form.test.js +4354 -4508
  174. package/lib/components/form/tests/components.js +73 -64
  175. package/lib/components/index.js +7 -0
  176. package/lib/components/system/SystemBackgroundTasksTable.js +1 -2
  177. package/lib/components/system/SystemCassandraForm.js +1 -2
  178. package/lib/components/system/SystemElasticSearchForm.js +1 -2
  179. package/lib/components/system/SystemFilestoreForm.js +2 -3
  180. package/lib/components/system/SystemForm.js +1 -2
  181. package/lib/components/system/SystemIngressForm.js +1 -2
  182. package/lib/components/system/SystemSecurityForm.js +1 -2
  183. package/lib/components/system/SystemSmtpForm.js +1 -2
  184. package/lib/components/system/SystemTaskAdapterForm.js +1 -2
  185. package/lib/components/system/SystemTrustedCertificateForm.js +1 -2
  186. package/lib/components/system/SystemTrustedCertificatesTable.js +1 -2
  187. package/lib/components/system/SystemUserForm.js +1 -2
  188. package/lib/components/system/helpers.js +11 -21
  189. package/lib/components/system/spaces/SystemSpaceForm.js +2 -3
  190. package/lib/components/system/spaces/SystemTenantForm.js +2 -3
  191. package/lib/components/system/spaces/SystemTenantTable.js +1 -2
  192. package/lib/components/table/Table.js +48 -51
  193. package/lib/components/table/Table.redux.js +161 -188
  194. package/lib/components/table/Table.test.js +115 -123
  195. package/lib/components/table/defaults/BodyCell.js +1 -2
  196. package/lib/components/table/defaults/BodyRow.js +1 -2
  197. package/lib/components/table/defaults/BooleanFilter.js +1 -2
  198. package/lib/components/table/defaults/ColumnControl.js +1 -2
  199. package/lib/components/table/defaults/EmptyBodyRow.js +1 -2
  200. package/lib/components/table/defaults/FilterLayout.js +1 -2
  201. package/lib/components/table/defaults/Footer.js +1 -2
  202. package/lib/components/table/defaults/FooterCell.js +1 -2
  203. package/lib/components/table/defaults/FooterRow.js +1 -2
  204. package/lib/components/table/defaults/Header.js +1 -2
  205. package/lib/components/table/defaults/HeaderCell.js +1 -2
  206. package/lib/components/table/defaults/HeaderRow.js +1 -2
  207. package/lib/components/table/defaults/PaginationControl.js +2 -4
  208. package/lib/components/table/defaults/TableBody.js +1 -2
  209. package/lib/components/table/defaults/TableLayout.js +1 -2
  210. package/lib/components/table/defaults/TextFilter.js +1 -2
  211. package/lib/components/table/defaults/index.js +2 -3
  212. package/lib/components/table/tests/Table.redux.test.js +162 -0
  213. package/lib/components/table/tests/Table.test.js +767 -0
  214. package/lib/components/table/tests/components.js +182 -0
  215. package/lib/components/task/builder/Connector.js +26 -11
  216. package/lib/components/task/builder/ConnectorForm.js +1 -2
  217. package/lib/components/task/builder/Node.js +18 -9
  218. package/lib/components/task/builder/NodeForm.js +1 -2
  219. package/lib/components/task/builder/NodeParametersForm.js +1 -2
  220. package/lib/components/task/builder/SvgCanvas.js +2 -3
  221. package/lib/components/task/builder/SvgText.js +2 -3
  222. package/lib/components/task/builder/TaskDefinitionConfigForm.js +3 -6
  223. package/lib/components/task/builder/TreeBuilder.js +14 -5
  224. package/lib/components/task/builder/builder.redux.js +187 -186
  225. package/lib/components/task/builder/constants.js +38 -76
  226. package/lib/components/task/builder/helpers.js +23 -40
  227. package/lib/components/task/builder/models.js +24 -35
  228. package/lib/components/task/category/TaskCategoryForm.js +2 -3
  229. package/lib/components/task/category/TaskCategoryTable.js +1 -2
  230. package/lib/components/task/common/UsageTable.js +1 -2
  231. package/lib/components/task/engine/EngineSettingsForm.js +2 -3
  232. package/lib/components/task/errors/RunErrorTable.js +2 -3
  233. package/lib/components/task/errors/SystemErrorsTable.js +1 -2
  234. package/lib/components/task/handlers/HandlerForm.js +2 -3
  235. package/lib/components/task/handlers/HandlerTable.js +1 -2
  236. package/lib/components/task/handlers/MissingHandlerTable.js +1 -2
  237. package/lib/components/task/policy_rule/PolicyRuleForm.js +2 -3
  238. package/lib/components/task/policy_rule/PolicyRuleTable.js +1 -2
  239. package/lib/components/task/runs/CreateManualTriggerForm.js +1 -2
  240. package/lib/components/task/runs/RunTable.js +2 -3
  241. package/lib/components/task/runs/RunTaskTable.js +1 -2
  242. package/lib/components/task/sources/SourceForm.js +1 -2
  243. package/lib/components/task/sources/SourceTable.js +1 -2
  244. package/lib/components/task/triggers/TriggerTable.js +2 -3
  245. package/lib/components/task/workflows/LinkedWorkflowForm.js +3 -5
  246. package/lib/components/task/workflows/LinkedWorkflowTable.js +1 -2
  247. package/lib/components/task/workflows/MissingRoutineTable.js +1 -2
  248. package/lib/components/task/workflows/WorkflowForm.js +91 -41
  249. package/lib/components/task/workflows/WorkflowTable.js +1 -2
  250. package/lib/helpers/SearchBuilder.js +2 -4
  251. package/lib/helpers/index.js +13 -26
  252. package/lib/index.js +3 -6
  253. package/lib/reducer.js +3 -5
  254. package/lib/saga.js +32 -48
  255. package/lib/store.js +32 -42
  256. package/package.json +12 -15
  257. package/lib/components/core/CoreFormModal.js +0 -64
  258. package/lib/components/core/CoreModal.js +0 -114
@@ -0,0 +1,767 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
5
+ var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
6
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
7
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactTestRenderer = require("react-test-renderer");
10
+ var _index = require("../../../index");
11
+ var _store = require("../../../store");
12
+ var _immutable = require("immutable");
13
+ var _fixtures = require("../../../../tests/fixtures");
14
+ var _defaults = require("../defaults");
15
+ var _Table = require("../Table");
16
+ var _components = require("./components");
17
+ var _excluded = ["dataSource", "filters", "filterDataSources", "columns", "tableOptions", "tableKey", "TableView"];
18
+ var buildProps = function buildProps(props) {
19
+ props.columnComponents = (0, _Table.extractColumnComponents)(props.columns);
20
+ return props;
21
+ };
22
+
23
+ // Things passed in from generateTables
24
+ // tableOptions, columns, dataSource, sortable
25
+
26
+ var TABLE_KEY = 'mock-table-key';
27
+ var mountTable = function mountTable(_ref) {
28
+ var dataSource = _ref.dataSource,
29
+ filters = _ref.filters,
30
+ filterDataSources = _ref.filterDataSources,
31
+ _ref$columns = _ref.columns,
32
+ columns = _ref$columns === void 0 ? [] : _ref$columns,
33
+ _ref$tableOptions = _ref.tableOptions,
34
+ tableOptions = _ref$tableOptions === void 0 ? {} : _ref$tableOptions,
35
+ _ref$tableKey = _ref.tableKey,
36
+ tableKey = _ref$tableKey === void 0 ? TABLE_KEY : _ref$tableKey,
37
+ _ref$TableView = _ref.TableView,
38
+ TableView = _ref$TableView === void 0 ? _components.TableViewMock : _ref$TableView,
39
+ tableProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
40
+ // Generate a new Table type using the options.
41
+ var Table = (0, _Table.generateTable)({
42
+ dataSource: dataSource,
43
+ columns: columns,
44
+ filters: filters,
45
+ filterDataSources: filterDataSources,
46
+ tableOptions: Object.keys(tableOptions)
47
+ });
48
+ return (0, _reactTestRenderer.act)(function () {
49
+ return new Promise(function (resolve) {
50
+ var result = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, {
51
+ components: _components.mockTableConfig
52
+ }, /*#__PURE__*/_react["default"].createElement(Table, Object.assign({
53
+ tableKey: tableKey,
54
+ uncontrolled: true
55
+ }, tableProps, tableOptions), function (props) {
56
+ return /*#__PURE__*/_react["default"].createElement(TableView, props);
57
+ })));
58
+ var ready = function ready() {
59
+ return !(_store.store.getState().getIn(['tables', tableKey, 'loading'], true) || _store.store.getState().getIn(['tables', tableKey, 'initializing'], true));
60
+ };
61
+ if (ready()) {
62
+ resolve(result);
63
+ } else {
64
+ var unsub = _store.store.subscribe(function () {
65
+ if (ready()) {
66
+ resolve(result);
67
+ // Remove the store listener since we're done.
68
+ unsub();
69
+ }
70
+ });
71
+ }
72
+ });
73
+ });
74
+ };
75
+
76
+ // Helper function to find an element within the rendered component
77
+ var getByTestId = function getByTestId(json, id) {
78
+ var _json$props;
79
+ var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
80
+ if ((json === null || json === void 0 ? void 0 : (_json$props = json.props) === null || _json$props === void 0 ? void 0 : _json$props['data-testid']) === id) {
81
+ return json;
82
+ }
83
+ if (Array.isArray(json === null || json === void 0 ? void 0 : json.children)) {
84
+ return json.children.map(function (child) {
85
+ return getByTestId(child, id, depth + 1);
86
+ }).find(Boolean);
87
+ }
88
+ if (depth === 0) {
89
+ throw new Error("Cannot find element with test id: '".concat(id, "'"));
90
+ }
91
+ return undefined;
92
+ };
93
+
94
+ /*
95
+
96
+ * Repeat for: server-side, server-side w/client sort and paginate, client-side
97
+ * test sorting by column
98
+ * test sorting changing direction
99
+ * test default sort parameters
100
+
101
+ * test pure-client-side (data prop passed)
102
+
103
+ * test overriding default components for whole table
104
+ * test altering columns
105
+ ** changing component
106
+ ** What else *can* be changed???
107
+ * test adding columns
108
+ * test valueTransform
109
+ * test columnSet
110
+ * test pageSize
111
+ * test sortable
112
+ * test omit header
113
+ * test include footer
114
+
115
+
116
+ */
117
+
118
+ describe('<Table />', function () {
119
+ describe('render', function () {
120
+ var data, columns, wrapper, dataSourceFn;
121
+ beforeEach(function () {
122
+ data = {
123
+ mockData: [{
124
+ name: 'test',
125
+ status: 'active'
126
+ }]
127
+ };
128
+ columns = [{
129
+ value: 'name',
130
+ title: 'Name',
131
+ sortable: true,
132
+ filter: 'startsWith',
133
+ type: 'text'
134
+ }, {
135
+ value: 'status',
136
+ title: 'Status',
137
+ sortable: true,
138
+ filter: 'equals',
139
+ type: 'text',
140
+ options: function options() {
141
+ return [{
142
+ label: 'Active',
143
+ value: 'active'
144
+ }, {
145
+ label: 'Inactive',
146
+ value: 'inactive'
147
+ }];
148
+ }
149
+ }];
150
+ dataSourceFn = jest.fn(function () {
151
+ return Promise.resolve(data);
152
+ });
153
+ });
154
+ afterEach(function () {
155
+ if (wrapper) {
156
+ wrapper.unmount();
157
+ }
158
+ });
159
+ test('kitchen sink', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
160
+ var addColumns;
161
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
162
+ while (1) switch (_context.prev = _context.next) {
163
+ case 0:
164
+ addColumns = [{
165
+ value: '_action',
166
+ title: 'Actions'
167
+ }];
168
+ _context.next = 3;
169
+ return mountTable({
170
+ columns: columns,
171
+ addColumns: addColumns,
172
+ dataSource: function dataSource(_tableOptions) {
173
+ return {
174
+ fn: dataSourceFn,
175
+ params: function params(_paramData) {
176
+ return [];
177
+ },
178
+ transform: function transform(result) {
179
+ return {
180
+ data: result.mockData
181
+ };
182
+ }
183
+ };
184
+ }
185
+ });
186
+ case 3:
187
+ wrapper = _context.sent;
188
+ expect(getByTestId(wrapper.toJSON(), 'TableViewMock')).toMatchSnapshot();
189
+ case 5:
190
+ case "end":
191
+ return _context.stop();
192
+ }
193
+ }, _callee);
194
+ })));
195
+ describe('filters', function () {
196
+ test('legacy filters', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
197
+ var filterLayout;
198
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
199
+ while (1) switch (_context2.prev = _context2.next) {
200
+ case 0:
201
+ _context2.next = 2;
202
+ return mountTable({
203
+ dataSource: function dataSource(_tableOptions) {
204
+ return {
205
+ fn: dataSourceFn,
206
+ params: function params(_paramData) {
207
+ return [];
208
+ },
209
+ transform: function transform(result) {
210
+ return {
211
+ data: result.mockData
212
+ };
213
+ }
214
+ };
215
+ }
216
+ });
217
+ case 2:
218
+ wrapper = _context2.sent;
219
+ filterLayout = getByTestId(wrapper.toJSON(), 'FilterLayoutMock');
220
+ expect(filterLayout).toBeDefined();
221
+ expect(filterLayout).toMatchSnapshot();
222
+ case 6:
223
+ case "end":
224
+ return _context2.stop();
225
+ }
226
+ }, _callee2);
227
+ })));
228
+ test('filter form', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee3() {
229
+ var filterForm;
230
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
231
+ while (1) switch (_context3.prev = _context3.next) {
232
+ case 0:
233
+ _context3.next = 2;
234
+ return mountTable({
235
+ filters: function filters() {
236
+ return function () {
237
+ return [{
238
+ name: 'name',
239
+ label: 'Name',
240
+ type: 'text'
241
+ }, {
242
+ name: 'status',
243
+ label: 'Status',
244
+ type: 'text'
245
+ }];
246
+ };
247
+ },
248
+ dataSource: function dataSource(_tableOptions) {
249
+ return {
250
+ fn: dataSourceFn,
251
+ params: function params(_paramData) {
252
+ return [];
253
+ },
254
+ transform: function transform(result) {
255
+ return {
256
+ data: result.mockData
257
+ };
258
+ }
259
+ };
260
+ }
261
+ });
262
+ case 2:
263
+ wrapper = _context3.sent;
264
+ filterForm = getByTestId(wrapper.toJSON(), 'FormLayoutMock');
265
+ expect(filterForm).toBeDefined();
266
+ expect(filterForm).toMatchSnapshot();
267
+ case 6:
268
+ case "end":
269
+ return _context3.stop();
270
+ }
271
+ }, _callee3);
272
+ })));
273
+ });
274
+ describe('dataSource', function () {
275
+ test('dataSource resolves', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee4() {
276
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee4$(_context4) {
277
+ while (1) switch (_context4.prev = _context4.next) {
278
+ case 0:
279
+ _context4.next = 2;
280
+ return mountTable({
281
+ dataSource: function dataSource(_tableOptions) {
282
+ return {
283
+ fn: dataSourceFn,
284
+ params: function params(_paramData) {
285
+ return [];
286
+ },
287
+ transform: function transform(result) {
288
+ return {
289
+ data: result.mockData
290
+ };
291
+ }
292
+ };
293
+ }
294
+ });
295
+ case 2:
296
+ wrapper = _context4.sent;
297
+ expect(getByTestId(wrapper.toJSON(), 'TableViewMock')).toMatchSnapshot();
298
+ expect(dataSourceFn.mock.calls).toMatchSnapshot();
299
+ case 5:
300
+ case "end":
301
+ return _context4.stop();
302
+ }
303
+ }, _callee4);
304
+ })));
305
+ });
306
+ });
307
+ describe('build methods', function () {
308
+ var props;
309
+ var data = [];
310
+ var columns = (0, _immutable.List)([]);
311
+ var columnSet = (0, _immutable.List)([]);
312
+ var wrapper;
313
+ beforeEach(function () {
314
+ data = (0, _fixtures.users)(2);
315
+ columns = (0, _immutable.List)([(0, _immutable.Map)({
316
+ value: 'username',
317
+ title: 'Username'
318
+ })]);
319
+ columnSet = (0, _immutable.List)(['username']);
320
+ props = {
321
+ // Spread in the default components since the method tests will not be getting
322
+ // any components from the context since we're bypassing the top level `Table`
323
+ // component for testing.
324
+ components: (0, _objectSpread2["default"])({}, _defaults.DefaultTableConfig.toJS()),
325
+ data: data,
326
+ columns: columns,
327
+ columnSet: columnSet,
328
+ rows: (0, _immutable.List)(data).map(function (r) {
329
+ return (0, _immutable.Map)(r);
330
+ })
331
+ };
332
+ });
333
+ afterEach(function () {
334
+ if (wrapper) {
335
+ wrapper.unmount();
336
+ }
337
+ });
338
+ describe('#buildTable', function () {
339
+ test('it renders normally', function () {
340
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTable)(buildProps(props))));
341
+ expect(wrapper.toJSON().type).toEqual('table');
342
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-table');
343
+ });
344
+ test('it renders a custom table', function () {
345
+ var TableLayout = function TableLayout() {
346
+ return /*#__PURE__*/_react["default"].createElement("table", {
347
+ className: "custom-table"
348
+ });
349
+ };
350
+ props.components.TableLayout = TableLayout;
351
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTable)(buildProps(props))));
352
+ expect(wrapper.toJSON().type).toEqual('table');
353
+ expect(wrapper.toJSON().props.className).toEqual('custom-table');
354
+ });
355
+ });
356
+ describe('#buildTableHeader', function () {
357
+ test('it renders normally', function () {
358
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
359
+ expect(wrapper.toJSON().type).toEqual('thead');
360
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-thead');
361
+ });
362
+ test('it does not render when omitHeader is set', function () {
363
+ props.omitHeader = true;
364
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
365
+ expect(wrapper.toJSON()).toBeNull();
366
+ });
367
+ test('it renders a custom thead', function () {
368
+ var Header = function Header() {
369
+ return /*#__PURE__*/_react["default"].createElement("thead", {
370
+ className: "custom-thead"
371
+ });
372
+ };
373
+ props.components.Header = Header;
374
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
375
+ expect(wrapper.toJSON().type).toEqual('thead');
376
+ expect(wrapper.toJSON().props.className).toEqual('custom-thead');
377
+ });
378
+ });
379
+ describe('#buildTableHeaderRow', function () {
380
+ test('it renders normally', function () {
381
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderRow)(buildProps(props))));
382
+ expect(wrapper.toJSON().type).toEqual('tr');
383
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-tr');
384
+ });
385
+ test('it renders a custom thead', function () {
386
+ var HeaderRow = function HeaderRow() {
387
+ return /*#__PURE__*/_react["default"].createElement("tr", {
388
+ className: "custom-tr"
389
+ });
390
+ };
391
+ props.components.HeaderRow = HeaderRow;
392
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderRow)(buildProps(props))));
393
+ expect(wrapper.toJSON().type).toEqual('tr');
394
+ expect(wrapper.toJSON().props.className).toEqual('custom-tr');
395
+ });
396
+ });
397
+ describe('#buildTableHeaderCell', function () {
398
+ test('it renders normally', function () {
399
+ var column = columns.first();
400
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderCell)(buildProps(props))(column, 0)));
401
+ expect(wrapper.toJSON().type).toEqual('th');
402
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-th');
403
+ });
404
+ test('it renders a custom th', function () {
405
+ var column = columns.first();
406
+ var HeaderCell = function HeaderCell() {
407
+ return /*#__PURE__*/_react["default"].createElement("th", {
408
+ className: "custom-th"
409
+ });
410
+ };
411
+ props.components.HeaderCell = HeaderCell;
412
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderCell)(buildProps(props))(column, 0)));
413
+ expect(wrapper.toJSON().type).toEqual('th');
414
+ expect(wrapper.toJSON().props.className).toEqual('custom-th');
415
+ });
416
+ test('it renders a custom th for a specific column', function () {
417
+ var HeaderCell = function HeaderCell() {
418
+ return /*#__PURE__*/_react["default"].createElement("th", {
419
+ className: "custom-cell-th"
420
+ });
421
+ };
422
+ props.columns = props.columns.push((0, _immutable.Map)({
423
+ value: 'displayName',
424
+ title: 'DisplayName',
425
+ components: {
426
+ HeaderCell: HeaderCell
427
+ }
428
+ }));
429
+ props.columnSet = props.columnSet.push('displayName');
430
+ var column = props.columns.last();
431
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderCell)(buildProps(props))(column, 0)));
432
+ expect(wrapper.toJSON().type).toEqual('th');
433
+ expect(wrapper.toJSON().props.className).toEqual('custom-cell-th');
434
+ });
435
+ });
436
+ describe('#buildTableBody', function () {
437
+ test('it renders normally', function () {
438
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableBody)(buildProps(props))));
439
+ expect(wrapper.toJSON().type).toEqual('tbody');
440
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-tbody');
441
+ });
442
+ test('it renders a custom tbody', function () {
443
+ var Header = function Header() {
444
+ return /*#__PURE__*/_react["default"].createElement("tbody", {
445
+ className: "custom-tbody"
446
+ });
447
+ };
448
+ props.components.Header = Header;
449
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
450
+ expect(wrapper.toJSON().type).toEqual('tbody');
451
+ expect(wrapper.toJSON().props.className).toEqual('custom-tbody');
452
+ });
453
+ });
454
+ describe('#buildTableBodyRows', function () {
455
+ test('it renders rows normally', function () {
456
+ var _getByTestId, _getByTestId2, _getByTestId2$childre, _getByTestId2$childre2, _getByTestId3, _getByTestId3$childre, _getByTestId3$childre2, _getByTestId3$childre3;
457
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
458
+ "data-testid": "TableBodyMock"
459
+ }, (0, _Table.buildTableBodyRows)(buildProps(props))))));
460
+ expect((_getByTestId = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId === void 0 ? void 0 : _getByTestId.children).toHaveLength(props.rows.size);
461
+ expect((_getByTestId2 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId2 === void 0 ? void 0 : (_getByTestId2$childre = _getByTestId2.children) === null || _getByTestId2$childre === void 0 ? void 0 : (_getByTestId2$childre2 = _getByTestId2$childre[0]) === null || _getByTestId2$childre2 === void 0 ? void 0 : _getByTestId2$childre2.type).toEqual('tr');
462
+ expect((_getByTestId3 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId3 === void 0 ? void 0 : (_getByTestId3$childre = _getByTestId3.children) === null || _getByTestId3$childre === void 0 ? void 0 : (_getByTestId3$childre2 = _getByTestId3$childre[0]) === null || _getByTestId3$childre2 === void 0 ? void 0 : (_getByTestId3$childre3 = _getByTestId3$childre2.props) === null || _getByTestId3$childre3 === void 0 ? void 0 : _getByTestId3$childre3.className).not.toEqual('custom-tr');
463
+ });
464
+ test('it renders custom rows', function () {
465
+ var _getByTestId4, _getByTestId5, _getByTestId5$childre, _getByTestId5$childre2, _getByTestId6, _getByTestId6$childre, _getByTestId6$childre2, _getByTestId6$childre3;
466
+ var BodyRow = function BodyRow() {
467
+ return /*#__PURE__*/_react["default"].createElement("tr", {
468
+ className: "custom-tr"
469
+ });
470
+ };
471
+ props.components.BodyRow = BodyRow;
472
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
473
+ "data-testid": "TableBodyMock"
474
+ }, (0, _Table.buildTableBodyRows)(buildProps(props))))));
475
+ expect((_getByTestId4 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId4 === void 0 ? void 0 : _getByTestId4.children).toHaveLength(props.rows.size);
476
+ expect((_getByTestId5 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId5 === void 0 ? void 0 : (_getByTestId5$childre = _getByTestId5.children) === null || _getByTestId5$childre === void 0 ? void 0 : (_getByTestId5$childre2 = _getByTestId5$childre[0]) === null || _getByTestId5$childre2 === void 0 ? void 0 : _getByTestId5$childre2.type).toEqual('tr');
477
+ expect((_getByTestId6 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId6 === void 0 ? void 0 : (_getByTestId6$childre = _getByTestId6.children) === null || _getByTestId6$childre === void 0 ? void 0 : (_getByTestId6$childre2 = _getByTestId6$childre[0]) === null || _getByTestId6$childre2 === void 0 ? void 0 : (_getByTestId6$childre3 = _getByTestId6$childre2.props) === null || _getByTestId6$childre3 === void 0 ? void 0 : _getByTestId6$childre3.className).toEqual('custom-tr');
478
+ });
479
+ test('it renders default empty row', function () {
480
+ var _getByTestId7, _getByTestId8, _getByTestId8$childre, _getByTestId8$childre2, _getByTestId9, _getByTestId9$childre, _getByTestId9$childre2, _getByTestId9$childre3;
481
+ props.rows = (0, _immutable.List)([]);
482
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
483
+ "data-testid": "TableBodyMock"
484
+ }, (0, _Table.buildTableBodyRows)(buildProps(props))))));
485
+ expect((_getByTestId7 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId7 === void 0 ? void 0 : _getByTestId7.children).toHaveLength(1);
486
+ expect((_getByTestId8 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId8 === void 0 ? void 0 : (_getByTestId8$childre = _getByTestId8.children) === null || _getByTestId8$childre === void 0 ? void 0 : (_getByTestId8$childre2 = _getByTestId8$childre[0]) === null || _getByTestId8$childre2 === void 0 ? void 0 : _getByTestId8$childre2.type).toEqual('tr');
487
+ expect((_getByTestId9 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId9 === void 0 ? void 0 : (_getByTestId9$childre = _getByTestId9.children) === null || _getByTestId9$childre === void 0 ? void 0 : (_getByTestId9$childre2 = _getByTestId9$childre[0]) === null || _getByTestId9$childre2 === void 0 ? void 0 : (_getByTestId9$childre3 = _getByTestId9$childre2.props) === null || _getByTestId9$childre3 === void 0 ? void 0 : _getByTestId9$childre3.className).not.toEqual('custom-empty-tr');
488
+ });
489
+ test('it renders custom empty row', function () {
490
+ var _getByTestId10, _getByTestId11, _getByTestId11$childr, _getByTestId11$childr2, _getByTestId12, _getByTestId12$childr, _getByTestId12$childr2, _getByTestId12$childr3;
491
+ var EmptyBodyRow = function EmptyBodyRow() {
492
+ return /*#__PURE__*/_react["default"].createElement("tr", {
493
+ className: "custom-empty-tr"
494
+ });
495
+ };
496
+ props.rows = (0, _immutable.List)([]);
497
+ props.components.EmptyBodyRow = EmptyBodyRow;
498
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
499
+ "data-testid": "TableBodyMock"
500
+ }, (0, _Table.buildTableBodyRows)(buildProps(props))))));
501
+ expect((_getByTestId10 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId10 === void 0 ? void 0 : _getByTestId10.children).toHaveLength(1);
502
+ expect((_getByTestId11 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId11 === void 0 ? void 0 : (_getByTestId11$childr = _getByTestId11.children) === null || _getByTestId11$childr === void 0 ? void 0 : (_getByTestId11$childr2 = _getByTestId11$childr[0]) === null || _getByTestId11$childr2 === void 0 ? void 0 : _getByTestId11$childr2.type).toEqual('tr');
503
+ expect((_getByTestId12 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId12 === void 0 ? void 0 : (_getByTestId12$childr = _getByTestId12.children) === null || _getByTestId12$childr === void 0 ? void 0 : (_getByTestId12$childr2 = _getByTestId12$childr[0]) === null || _getByTestId12$childr2 === void 0 ? void 0 : (_getByTestId12$childr3 = _getByTestId12$childr2.props) === null || _getByTestId12$childr3 === void 0 ? void 0 : _getByTestId12$childr3.className).toEqual('custom-empty-tr');
504
+ });
505
+ });
506
+ describe('#buildTableBodyCells', function () {
507
+ test('it renders cells normally', function () {
508
+ var _getByTestId13, _getByTestId14, _getByTestId14$childr, _getByTestId14$childr2, _getByTestId15, _getByTestId15$childr, _getByTestId15$childr2, _getByTestId15$childr3;
509
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", {
510
+ "data-testid": "TableBodyRowMock"
511
+ }, (0, _Table.buildTableBodyCells)(buildProps(props), props.rows.first(), 0))))));
512
+ expect((_getByTestId13 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId13 === void 0 ? void 0 : _getByTestId13.children).toHaveLength(props.columnSet.size);
513
+ expect((_getByTestId14 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId14 === void 0 ? void 0 : (_getByTestId14$childr = _getByTestId14.children) === null || _getByTestId14$childr === void 0 ? void 0 : (_getByTestId14$childr2 = _getByTestId14$childr[0]) === null || _getByTestId14$childr2 === void 0 ? void 0 : _getByTestId14$childr2.type).toEqual('td');
514
+ expect((_getByTestId15 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId15 === void 0 ? void 0 : (_getByTestId15$childr = _getByTestId15.children) === null || _getByTestId15$childr === void 0 ? void 0 : (_getByTestId15$childr2 = _getByTestId15$childr[0]) === null || _getByTestId15$childr2 === void 0 ? void 0 : (_getByTestId15$childr3 = _getByTestId15$childr2.props) === null || _getByTestId15$childr3 === void 0 ? void 0 : _getByTestId15$childr3.className).not.toEqual('custom-td');
515
+ });
516
+ test('it renders custom cells', function () {
517
+ var _getByTestId16, _getByTestId17, _getByTestId17$childr, _getByTestId17$childr2, _getByTestId18, _getByTestId18$childr, _getByTestId18$childr2, _getByTestId18$childr3;
518
+ var BodyCell = function BodyCell() {
519
+ return /*#__PURE__*/_react["default"].createElement("td", {
520
+ className: "custom-td"
521
+ });
522
+ };
523
+ props.components.BodyCell = BodyCell;
524
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", {
525
+ "data-testid": "TableBodyRowMock"
526
+ }, (0, _Table.buildTableBodyCells)(buildProps(props), props.rows.first(), 0))))));
527
+ expect((_getByTestId16 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId16 === void 0 ? void 0 : _getByTestId16.children).toHaveLength(props.columnSet.size);
528
+ expect((_getByTestId17 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId17 === void 0 ? void 0 : (_getByTestId17$childr = _getByTestId17.children) === null || _getByTestId17$childr === void 0 ? void 0 : (_getByTestId17$childr2 = _getByTestId17$childr[0]) === null || _getByTestId17$childr2 === void 0 ? void 0 : _getByTestId17$childr2.type).toEqual('td');
529
+ expect((_getByTestId18 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId18 === void 0 ? void 0 : (_getByTestId18$childr = _getByTestId18.children) === null || _getByTestId18$childr === void 0 ? void 0 : (_getByTestId18$childr2 = _getByTestId18$childr[0]) === null || _getByTestId18$childr2 === void 0 ? void 0 : (_getByTestId18$childr3 = _getByTestId18$childr2.props) === null || _getByTestId18$childr3 === void 0 ? void 0 : _getByTestId18$childr3.className).toEqual('custom-td');
530
+ });
531
+ test('it renders custom column cells', function () {
532
+ var _getByTestId19, _getByTestId20, _getByTestId20$childr, _getByTestId20$childr2, _getByTestId21, _getByTestId21$childr, _getByTestId21$childr2, _getByTestId21$childr3, _getByTestId22, _getByTestId22$childr, _getByTestId22$childr2, _getByTestId22$childr3;
533
+ var BodyCell = function BodyCell() {
534
+ return /*#__PURE__*/_react["default"].createElement("td", {
535
+ className: "custom-td"
536
+ });
537
+ };
538
+ props.columns = props.columns.push((0, _immutable.Map)({
539
+ value: 'displayName',
540
+ title: 'DisplayName',
541
+ components: {
542
+ BodyCell: BodyCell
543
+ }
544
+ }));
545
+ props.columnSet = props.columnSet.push('displayName');
546
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", {
547
+ "data-testid": "TableBodyRowMock"
548
+ }, (0, _Table.buildTableBodyCells)(buildProps(props), props.rows.first(), 0))))));
549
+ expect((_getByTestId19 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId19 === void 0 ? void 0 : _getByTestId19.children).toHaveLength(props.columnSet.size);
550
+ expect((_getByTestId20 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId20 === void 0 ? void 0 : (_getByTestId20$childr = _getByTestId20.children) === null || _getByTestId20$childr === void 0 ? void 0 : (_getByTestId20$childr2 = _getByTestId20$childr[0]) === null || _getByTestId20$childr2 === void 0 ? void 0 : _getByTestId20$childr2.type).toEqual('td');
551
+ expect((_getByTestId21 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId21 === void 0 ? void 0 : (_getByTestId21$childr = _getByTestId21.children) === null || _getByTestId21$childr === void 0 ? void 0 : (_getByTestId21$childr2 = _getByTestId21$childr[0]) === null || _getByTestId21$childr2 === void 0 ? void 0 : (_getByTestId21$childr3 = _getByTestId21$childr2.props) === null || _getByTestId21$childr3 === void 0 ? void 0 : _getByTestId21$childr3.className).not.toEqual('custom-td');
552
+ expect((_getByTestId22 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId22 === void 0 ? void 0 : (_getByTestId22$childr = _getByTestId22.children) === null || _getByTestId22$childr === void 0 ? void 0 : (_getByTestId22$childr2 = _getByTestId22$childr[props.columnSet.size - 1]) === null || _getByTestId22$childr2 === void 0 ? void 0 : (_getByTestId22$childr3 = _getByTestId22$childr2.props) === null || _getByTestId22$childr3 === void 0 ? void 0 : _getByTestId22$childr3.className).toEqual('custom-td');
553
+ });
554
+ });
555
+ describe('#buildTableFooter', function () {
556
+ test('it does not render normally', function () {
557
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooter)(buildProps(props))));
558
+ expect(wrapper.toJSON()).toBeNull();
559
+ });
560
+ test('it renders with includeFooter', function () {
561
+ props.includeFooter = true;
562
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooter)(buildProps(props))));
563
+ expect(wrapper.toJSON().type).toEqual('tfoot');
564
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-tfoot');
565
+ });
566
+ test('it renders a custom tfoot', function () {
567
+ var Footer = function Footer() {
568
+ return /*#__PURE__*/_react["default"].createElement("tfoot", {
569
+ className: "custom-tfoot"
570
+ });
571
+ };
572
+ props.includeFooter = true;
573
+ props.components.Footer = Footer;
574
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooter)(buildProps(props))));
575
+ expect(wrapper.toJSON().type).toEqual('tfoot');
576
+ expect(wrapper.toJSON().props.className).toEqual('custom-tfoot');
577
+ });
578
+ });
579
+ describe('#buildTableFooterRow', function () {
580
+ test('it renders normally', function () {
581
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooterRow)(buildProps(props))));
582
+ expect(wrapper.toJSON().type).toEqual('tr');
583
+ expect(wrapper.toJSON().props.className).not.toEqual('custom-tr');
584
+ });
585
+ test('it renders a custom tr', function () {
586
+ var FooterRow = function FooterRow() {
587
+ return /*#__PURE__*/_react["default"].createElement("tr", {
588
+ className: "custom-tr"
589
+ });
590
+ };
591
+ props.components.FooterRow = FooterRow;
592
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooterRow)(buildProps(props))));
593
+ expect(wrapper.toJSON().type).toEqual('tr');
594
+ expect(wrapper.toJSON().props.className).toEqual('custom-tr');
595
+ });
596
+ });
597
+ describe('#buildTableFooterCells', function () {
598
+ test('it renders normally', function () {
599
+ var _getByTestId23, _getByTestId24, _getByTestId24$childr, _getByTestId24$childr2, _getByTestId25, _getByTestId25$childr, _getByTestId25$childr2, _getByTestId25$childr3;
600
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("tfoot", null, /*#__PURE__*/_react["default"].createElement("tr", {
601
+ "data-testid": "FooterRowMock"
602
+ }, (0, _Table.buildTableFooterCells)(buildProps(props))))));
603
+ expect((_getByTestId23 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId23 === void 0 ? void 0 : _getByTestId23.children).toHaveLength(props.columnSet.size);
604
+ expect((_getByTestId24 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId24 === void 0 ? void 0 : (_getByTestId24$childr = _getByTestId24.children) === null || _getByTestId24$childr === void 0 ? void 0 : (_getByTestId24$childr2 = _getByTestId24$childr[0]) === null || _getByTestId24$childr2 === void 0 ? void 0 : _getByTestId24$childr2.type).toEqual('td');
605
+ expect((_getByTestId25 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId25 === void 0 ? void 0 : (_getByTestId25$childr = _getByTestId25.children) === null || _getByTestId25$childr === void 0 ? void 0 : (_getByTestId25$childr2 = _getByTestId25$childr[0]) === null || _getByTestId25$childr2 === void 0 ? void 0 : (_getByTestId25$childr3 = _getByTestId25$childr2.props) === null || _getByTestId25$childr3 === void 0 ? void 0 : _getByTestId25$childr3.className).not.toEqual('custom-td');
606
+ });
607
+ test('it renders a custom td', function () {
608
+ var _getByTestId26, _getByTestId27, _getByTestId27$childr, _getByTestId27$childr2, _getByTestId28, _getByTestId28$childr, _getByTestId28$childr2, _getByTestId28$childr3;
609
+ var FooterCell = function FooterCell() {
610
+ return /*#__PURE__*/_react["default"].createElement("td", {
611
+ className: "custom-td"
612
+ });
613
+ };
614
+ props.components.FooterCell = FooterCell;
615
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("tfoot", null, /*#__PURE__*/_react["default"].createElement("tr", {
616
+ "data-testid": "FooterRowMock"
617
+ }, (0, _Table.buildTableFooterCells)(buildProps(props))))));
618
+ expect((_getByTestId26 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId26 === void 0 ? void 0 : _getByTestId26.children).toHaveLength(props.columnSet.size);
619
+ expect((_getByTestId27 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId27 === void 0 ? void 0 : (_getByTestId27$childr = _getByTestId27.children) === null || _getByTestId27$childr === void 0 ? void 0 : (_getByTestId27$childr2 = _getByTestId27$childr[0]) === null || _getByTestId27$childr2 === void 0 ? void 0 : _getByTestId27$childr2.type).toEqual('td');
620
+ expect((_getByTestId28 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId28 === void 0 ? void 0 : (_getByTestId28$childr = _getByTestId28.children) === null || _getByTestId28$childr === void 0 ? void 0 : (_getByTestId28$childr2 = _getByTestId28$childr[0]) === null || _getByTestId28$childr2 === void 0 ? void 0 : (_getByTestId28$childr3 = _getByTestId28$childr2.props) === null || _getByTestId28$childr3 === void 0 ? void 0 : _getByTestId28$childr3.className).toEqual('custom-td');
621
+ });
622
+ test('it renders a custom td for a specific column', function () {
623
+ var _getByTestId29, _getByTestId30, _getByTestId30$childr, _getByTestId30$childr2, _getByTestId31, _getByTestId31$childr, _getByTestId31$childr2, _getByTestId31$childr3, _getByTestId32, _getByTestId32$childr, _getByTestId32$childr2, _getByTestId32$childr3;
624
+ var FooterCell = function FooterCell() {
625
+ return /*#__PURE__*/_react["default"].createElement("td", {
626
+ className: "custom-td"
627
+ });
628
+ };
629
+ props.columns = props.columns.push((0, _immutable.Map)({
630
+ value: 'displayName',
631
+ title: 'DisplayName',
632
+ components: {
633
+ FooterCell: FooterCell
634
+ }
635
+ }));
636
+ props.columnSet = props.columnSet.push('displayName');
637
+ wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("tfoot", null, /*#__PURE__*/_react["default"].createElement("tr", {
638
+ "data-testid": "FooterRowMock"
639
+ }, (0, _Table.buildTableFooterCells)(buildProps(props))))));
640
+ expect((_getByTestId29 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId29 === void 0 ? void 0 : _getByTestId29.children).toHaveLength(props.columnSet.size);
641
+ expect((_getByTestId30 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId30 === void 0 ? void 0 : (_getByTestId30$childr = _getByTestId30.children) === null || _getByTestId30$childr === void 0 ? void 0 : (_getByTestId30$childr2 = _getByTestId30$childr[0]) === null || _getByTestId30$childr2 === void 0 ? void 0 : _getByTestId30$childr2.type).toEqual('td');
642
+ expect((_getByTestId31 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId31 === void 0 ? void 0 : (_getByTestId31$childr = _getByTestId31.children) === null || _getByTestId31$childr === void 0 ? void 0 : (_getByTestId31$childr2 = _getByTestId31$childr[0]) === null || _getByTestId31$childr2 === void 0 ? void 0 : (_getByTestId31$childr3 = _getByTestId31$childr2.props) === null || _getByTestId31$childr3 === void 0 ? void 0 : _getByTestId31$childr3.className).not.toEqual('custom-td');
643
+ expect((_getByTestId32 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId32 === void 0 ? void 0 : (_getByTestId32$childr = _getByTestId32.children) === null || _getByTestId32$childr === void 0 ? void 0 : (_getByTestId32$childr2 = _getByTestId32$childr[props.columnSet.size - 1]) === null || _getByTestId32$childr2 === void 0 ? void 0 : (_getByTestId32$childr3 = _getByTestId32$childr2.props) === null || _getByTestId32$childr3 === void 0 ? void 0 : _getByTestId32$childr3.className).toEqual('custom-td');
644
+ });
645
+ });
646
+ });
647
+ describe('data manipulators', function () {
648
+ describe('#generateColumns', function () {
649
+ var columns;
650
+ var addColumns;
651
+ var alterColumns;
652
+ beforeEach(function () {
653
+ columns = [{
654
+ value: 'a',
655
+ title: 'A'
656
+ }];
657
+ addColumns = [{
658
+ value: 'b',
659
+ title: 'B'
660
+ }];
661
+ alterColumns = {};
662
+ });
663
+ test('combines the column config and additional columns', function () {
664
+ var total = columns.length + addColumns.length;
665
+ expect((0, _Table.generateColumns)(columns, addColumns, alterColumns).size).toBe(total);
666
+ });
667
+ test('alters columns with config', function () {
668
+ alterColumns.a = {
669
+ sortable: true
670
+ };
671
+ var columnConfig = (0, _Table.generateColumns)(columns, addColumns, alterColumns);
672
+ var column = columnConfig.find(function (c) {
673
+ return c.get('value') === columns[0].value;
674
+ });
675
+ expect(column.get('sortable')).toBeTruthy();
676
+ });
677
+ test('alters columns does not change value key', function () {
678
+ alterColumns.a = {
679
+ value: 'c'
680
+ };
681
+ var columnConfig = (0, _Table.generateColumns)(columns, addColumns, alterColumns);
682
+ var column = columnConfig.find(function (c) {
683
+ return c.get('value') === 'a';
684
+ });
685
+ expect(column).not.toBeUndefined();
686
+ });
687
+ });
688
+ describe('#sortColumns', function () {
689
+ test('sort columns returns expected sort order', function () {
690
+ var columns = (0, _immutable.List)([(0, _immutable.Map)({
691
+ value: 'a',
692
+ title: 'A'
693
+ }), (0, _immutable.Map)({
694
+ value: 'b',
695
+ title: 'B'
696
+ }), (0, _immutable.Map)({
697
+ value: 'c',
698
+ title: 'C'
699
+ })]);
700
+ var columnSet = (0, _immutable.List)(['b', 'a']);
701
+ expect((0, _Table.sortColumns)(columns, columnSet).toJS().map(function (c) {
702
+ return c.value;
703
+ }).join('')).toBe('bca');
704
+ });
705
+ });
706
+ describe('#getToggleableColumns', function () {
707
+ test('toggleable columns list is correct', function () {
708
+ var columns = (0, _immutable.List)([(0, _immutable.Map)({
709
+ value: 'a',
710
+ title: 'A',
711
+ toggleable: true
712
+ }), (0, _immutable.Map)({
713
+ value: 'b',
714
+ title: 'B'
715
+ }), (0, _immutable.Map)({
716
+ value: 'c',
717
+ title: 'C'
718
+ }), (0, _immutable.Map)({
719
+ value: 'd'
720
+ })]);
721
+ var columnSet = (0, _immutable.List)(['a', 'b', 'd']);
722
+ expect((0, _Table.getToggleableColumns)(columns, columnSet, 'table-key').toJS().map(function (c) {
723
+ return c.value;
724
+ }).join('')).toBe('ab');
725
+ });
726
+ });
727
+ xdescribe('#extractColumnComponents', function () {
728
+ var columns, addColumns, alterColumns;
729
+ beforeEach(function () {
730
+ columns = [{
731
+ value: 'first'
732
+ }, {
733
+ value: 'second',
734
+ components: {
735
+ BodyCell: 'two'
736
+ }
737
+ }, {
738
+ value: 'third'
739
+ }];
740
+ addColumns = [{
741
+ value: 'fourth'
742
+ }, {
743
+ value: 'fifth',
744
+ components: {
745
+ BodyCell: 'five'
746
+ }
747
+ }];
748
+ alterColumns = {
749
+ third: {
750
+ components: {
751
+ BodyCell: 'three'
752
+ }
753
+ }
754
+ };
755
+ });
756
+ xtest('returns a map of components with overrides', function () {
757
+ var result = (0, _Table.extractColumnComponents)({
758
+ columns: columns,
759
+ addColumns: addColumns,
760
+ alterColumns: alterColumns
761
+ });
762
+ console.log(columns);
763
+ expect(result.toJS()).toBe([]);
764
+ });
765
+ });
766
+ });
767
+ });