Skip to content

Commit

Permalink
perf(ramda): Use individual imports
Browse files Browse the repository at this point in the history
Import directly the function to avoid jest creating a context for all the ramda utilities
  • Loading branch information
Ne3l committed Jul 13, 2022
1 parent 985a98e commit 5496927
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"jest-diff": "^27.4.6",
"jest-matcher-utils": "^27.4.6",
"pretty-format": "^27.3.1",
"ramda": "^0.26.1",
"ramda": "^0.28.0",
"redent": "^2.0.0"
},
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion src/to-be-disabled.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { compose, defaultTo, includes, path, propEq, anyPass } from 'ramda';
import compose from 'ramda/src/compose';
import defaultTo from 'ramda/src/defaultTo';
import includes from 'ramda/src/includes';
import path from 'ramda/src/path';
import propEq from 'ramda/src/propEq';
import anyPass from 'ramda/src/anyPass';
import { matcherHint } from 'jest-matcher-utils';

import { checkReactElement, getType, printElement } from './utils';
Expand Down
11 changes: 5 additions & 6 deletions src/to-be-empty.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { matcherHint } from 'jest-matcher-utils';
import { compose, defaultTo, isEmpty, not, path } from 'ramda';
import compose from 'ramda/src/compose';
import defaultTo from 'ramda/src/defaultTo';
import path from 'ramda/src/path';
import isEmpty from 'ramda/src/isEmpty';

import { checkReactElement, printElement } from './utils';

export function toBeEmpty(element) {
checkReactElement(element, toBeEmpty, this);

return {
pass: compose(
isEmpty,
defaultTo({}),
path(['props', 'children']),
)(element),
pass: compose(isEmpty, defaultTo({}), path(['props', 'children']))(element),
message: () => {
return [
matcherHint(`${this.isNot ? '.not' : ''}.toBeEmpty`, 'element', ''),
Expand Down
2 changes: 1 addition & 1 deletion src/to-contain-element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { equals } from 'ramda';
import equals from 'ramda/src/equals';
import { matcherHint, RECEIVED_COLOR as receivedColor } from 'jest-matcher-utils';

import { checkReactElement, printElement } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion src/to-have-prop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { equals } from 'ramda';
import equals from 'ramda/src/equals';
import { matcherHint, stringify, printExpected } from 'jest-matcher-utils';
import { checkReactElement, getMessage } from './utils';

Expand Down
7 changes: 5 additions & 2 deletions src/to-have-style.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { matcherHint } from 'jest-matcher-utils';
import { diff } from 'jest-diff';
import chalk from 'chalk';
import { all, compose, flatten, mergeAll, toPairs } from 'ramda';

import compose from 'ramda/src/compose';
import all from 'ramda/src/all';
import flatten from 'ramda/src/flatten';
import mergeAll from 'ramda/src/mergeAll';
import toPairs from 'ramda/src/toPairs';
import { checkReactElement } from './utils';

function isSubset(expected, received) {
Expand Down
8 changes: 7 additions & 1 deletion src/to-have-text-content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { matcherHint } from 'jest-matcher-utils';
import { compose, defaultTo, is, join, map, path, filter } from 'ramda';
import compose from 'ramda/src/compose';
import defaultTo from 'ramda/src/defaultTo';
import is from 'ramda/src/is';
import join from 'ramda/src/join';
import map from 'ramda/src/map';
import path from 'ramda/src/path';
import filter from 'ramda/src/filter';

import { checkReactElement, getMessage, matches, normalize } from './utils';

Expand Down

0 comments on commit 5496927

Please sign in to comment.