Skip to content

Commit dc00cd9

Browse files
committed
chore: update jest config
1 parent 1626ead commit dc00cd9

File tree

6 files changed

+74
-66
lines changed

6 files changed

+74
-66
lines changed

packages/motif/.babelrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/motif/babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
},
10+
],
11+
'@babel/preset-react',
12+
'@babel/preset-typescript',
13+
],
14+
};

packages/motif/jest.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://jestjs.io/docs/en/configuration.html
44
*/
55

6-
export default {
6+
const config = {
77
// All imported modules in your tests should be mocked automatically
88
// automock: false,
99

@@ -165,7 +165,8 @@ export default {
165165

166166
// A map from regular expressions to paths to transformers
167167
transform: {
168-
'/node_modules/(lodash-es|d3-quadtree)/.+\\.(j|t)sx?$': 'ts-jest',
168+
'^.+\\.(ts|tsx)?$': 'ts-jest',
169+
'^.+\\.(js|jsx)$': 'babel-jest',
169170
},
170171

171172
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
@@ -185,3 +186,5 @@ export default {
185186
// Whether to use watchman for file crawling
186187
// watchman: true,
187188
};
189+
190+
export default config;

packages/motif/src/redux/graph/processors/import.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
processJson,
77
processNodeEdgeCsv,
88
processEdgeListCsv,
9-
verifySourceAndTargetExistence,
9+
verifySourceAndTargetExistence
1010
} from './data';
1111
import * as Utils from '../utils';
1212

@@ -22,7 +22,7 @@ import * as Utils from '../utils';
2222
export const importJson = async (
2323
json: GraphList | GraphData,
2424
accessors: Accessors,
25-
groupEdges: boolean,
25+
groupEdges = false
2626
): Promise<GraphList> => {
2727
const results: GraphList = [];
2828
const graphList: GraphList = Array.isArray(json) ? json : [json];
@@ -33,7 +33,7 @@ export const importJson = async (
3333
const processedData = await processJson(
3434
data,
3535
groupEdges,
36-
data?.key || data?.metadata?.key,
36+
data?.key || data?.metadata?.key
3737
);
3838

3939
const graphData = addRequiredFieldsJson(processedData, accessors);
@@ -73,7 +73,7 @@ export const importEdgeListCsv = async (
7373
csv: string,
7474
accessors: Accessors,
7575
groupEdges: boolean,
76-
metadataKey: string = null,
76+
metadataKey: string = null
7777
): Promise<GraphData> => {
7878
const { edgeSource, edgeTarget } = accessors;
7979

@@ -83,7 +83,7 @@ export const importEdgeListCsv = async (
8383
edgeSource,
8484
edgeTarget,
8585
groupEdges,
86-
metadataKey,
86+
metadataKey
8787
);
8888

8989
processedData.edges.forEach((edge: Edge) => {
@@ -124,15 +124,15 @@ export const importNodeEdgeCsv = async (
124124
edgeCsv: string[],
125125
accessors: Accessors,
126126
groupEdges: boolean,
127-
metadataKey: string = null,
127+
metadataKey: string = null
128128
): Promise<GraphData> => {
129129
try {
130130
const processedData: GraphData = await processNodeEdgeCsv(
131131
nodeCsv,
132132
edgeCsv,
133133
groupEdges,
134134
accessors,
135-
metadataKey,
135+
metadataKey
136136
);
137137

138138
const graphData = addRequiredFieldsJson(processedData, accessors);
@@ -162,7 +162,7 @@ export const importNodeEdgeCsv = async (
162162
*/
163163
export const addRequiredFieldsJson = (
164164
data: GraphData,
165-
accessors: Accessors,
165+
accessors: Accessors
166166
): GraphData => {
167167
for (const node of data.nodes) {
168168
addNodeFields(node, accessors);
@@ -206,7 +206,7 @@ export const addEdgeFields = (edge: Edge, accessors: Accessors): void => {
206206

207207
Object.assign(edge, {
208208
source: edgeSourceValue.toString(),
209-
target: edgeTargetValue.toString(),
209+
target: edgeTargetValue.toString()
210210
});
211211

212212
generateIdKey(edge, edgeID);
@@ -226,26 +226,26 @@ const generateIdKey = (object: any, idAccessor: string | undefined): void => {
226226
if (isUndefined(idAccessor)) {
227227
if (isUndefined(object.id)) {
228228
Object.assign(object, {
229-
id: shortid.generate(),
229+
id: shortid.generate()
230230
});
231231
}
232232
} else if (isUndefined(get(object, idAccessor))) {
233233
Object.assign(object, {
234-
id: shortid.generate(),
234+
id: shortid.generate()
235235
});
236236
} else if (isUndefined(object.id) && idAccessor) {
237237
const id = get(object, idAccessor).toString();
238238
Object.assign(object, {
239-
id,
239+
id
240240
});
241241
} else if (idAccessor === 'auto-generated') {
242242
Object.assign(object, {
243-
id: shortid.generate(),
243+
id: shortid.generate()
244244
});
245245
} else {
246246
const id = get(object, idAccessor).toString();
247247
Object.assign(object, {
248-
[idAccessor]: id,
248+
[idAccessor]: id
249249
});
250250
}
251251
};

0 commit comments

Comments
 (0)