Skip to content

Commit

Permalink
add Immutable pretty-format plugins for Immutable.OrderedSet and Immu… (
Browse files Browse the repository at this point in the history
#2899)

* add Immutable pretty-format plugins for Immutable.OrderedSet and Immutable.List

* adding immutable pretty-format plugins

* update yarn.lock with immutable library

* adding support for react components in Immutable pretty-format plugins

* adding copyright header

* refactor printImmutable method

* fix flow check

* add support for opts {min: false} for immutable plugins

* change ES2015 spread syntax to .concat

* add missing semicolon

* refactor printImmutable

* adding trailing comma when {min: false}

* refactor immutable tests using expect.extend toPrettyPrintTo
  • Loading branch information
cpenarrieta authored and cpojer committed Mar 6, 2017
1 parent 81e741d commit 25e9145
Show file tree
Hide file tree
Showing 15 changed files with 680 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"flow-bin": "^0.39.0",
"glob": "^7.1.1",
"graceful-fs": "^4.1.11",
"immutable": "^3.8.1",
"istanbul-api": "^1.1.0",
"istanbul-lib-coverage": "^1.0.0",
"jasmine-reporters": "^2.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-diff/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {DiffOptions} from './diffStrings';
const ReactElementPlugin = require('pretty-format/build/plugins/ReactElement');
const ReactTestComponentPlugin = require('pretty-format/build/plugins/ReactTestComponent');
const AsymmetricMatcherPlugin = require('pretty-format/build/plugins/AsymmetricMatcher');
const ImmutablePlugins = require('pretty-format/build/plugins/ImmutablePlugins');

const chalk = require('chalk');
const diffStrings = require('./diffStrings');
Expand All @@ -30,7 +31,7 @@ const PLUGINS = [
ReactTestComponentPlugin,
ReactElementPlugin,
AsymmetricMatcherPlugin,
];
].concat(ImmutablePlugins);
const FORMAT_OPTIONS = {
plugins: PLUGINS,
};
Expand Down
7 changes: 6 additions & 1 deletion packages/jest-matcher-utils/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
const chalk = require('chalk');
const prettyFormat = require('pretty-format');
const AsymmetricMatcherPlugin = require('pretty-format/build/plugins/AsymmetricMatcher');
const ReactElementPlugin = require('pretty-format/build/plugins/ReactElement');
const ImmutablePlugins = require('pretty-format/build/plugins/ImmutablePlugins');

const PLUGINS = [AsymmetricMatcherPlugin];
const PLUGINS = [
AsymmetricMatcherPlugin,
ReactElementPlugin,
].concat(ImmutablePlugins);

export type ValueType =
| 'array'
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/__tests__/plugins-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const testPath = names => {
it('gets plugins', () => {
const {getSerializers} = require('../plugins');
const plugins = getSerializers();
expect(plugins.length).toBe(2);
expect(plugins.length).toBe(8);
});

it('adds plugins from an empty array', () => testPath([]));
Expand Down
6 changes: 5 additions & 1 deletion packages/jest-snapshot/src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@

const ReactElementPlugin = require('pretty-format/build/plugins/ReactElement');
const ReactTestComponentPlugin = require('pretty-format/build/plugins/ReactTestComponent');
const ImmutablePlugins = require('pretty-format/build/plugins/ImmutablePlugins');

let PLUGINS = [ReactElementPlugin, ReactTestComponentPlugin];
let PLUGINS = [
ReactElementPlugin,
ReactTestComponentPlugin,
].concat(ImmutablePlugins);

// Prepend to list so the last added is the first tested.
exports.addSerializer = (plugin: any) => {
Expand Down
Loading

0 comments on commit 25e9145

Please sign in to comment.