Skip to content

Commit

Permalink
perf(ramda): Use individual imports (#79)
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

Co-authored-by: Nacho Lopez <nacho.lopez@manomano.com>
  • Loading branch information
Ne3l and Ne3l committed Aug 8, 2022
1 parent 985a98e commit 09d898d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 09d898d

Please sign in to comment.