diff --git a/.eslintrc.yml b/.eslintrc.yml index c6d7135..b2f22e2 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -6,14 +6,15 @@ env: commonjs: true es6: true -extends: 'eslint:recommended' +extends: + - eslint:recommended + - prettier rules: ## Possible Errors for-direction: error - no-extra-parens: error no-prototype-builtins: error no-template-curly-in-string: error @@ -27,9 +28,6 @@ rules: consistent-return: error curly: error default-case: error - dot-location: - - error - - property dot-notation: error eqeqeq: error guard-for-in: error @@ -43,7 +41,6 @@ rules: no-extend-native: error no-extra-bind: error no-extra-label: error - no-floating-decimal: error no-global-assign: error no-implicit-coercion: error no-implicit-globals: error @@ -52,7 +49,6 @@ rules: no-labels: error no-lone-blocks: error no-loop-func: error - no-multi-spaces: error no-multi-str: error no-new: error no-new-func: error @@ -73,7 +69,6 @@ rules: no-with: error prefer-promise-reject-errors: error radix: error - wrap-iife: error yoda: error ## Strict Mode @@ -103,126 +98,51 @@ rules: ## Stylistic Issues - array-bracket-newline: error - array-bracket-spacing: error - block-spacing: error - brace-style: error camelcase: error capitalized-comments: - error - always - ignoreConsecutiveComments: true - comma-dangle: - - error - - always-multiline - comma-spacing: error - comma-style: error - computed-property-spacing: error consistent-this: error - eol-last: error - func-call-spacing: error func-name-matching: error func-style: - error - declaration - allowArrowFunctions: true - function-paren-newline: - - error - - consistent id-match: error - indent: - - error - - 2 - - SwitchCase: 1 - key-spacing: error - keyword-spacing: error linebreak-style: - error - unix - lines-around-comment: error lines-between-class-members: error max-depth: error - max-len: - - error - - tabWidth: 2 - ignoreUrls: true - ignorePattern: \* expect\(.*\)\.to\.have\.[a-z.]*(keys|nested\.property) max-nested-callbacks: - error - max: 6 max-statements-per-line: error - multiline-ternary: - - error - - never new-cap: error - new-parens: error - newline-per-chained-call: error no-array-constructor: error no-bitwise: error no-continue: error no-lonely-if: error - no-mixed-operators: error no-multi-assign: error - no-multiple-empty-lines: error no-negated-condition: error no-nested-ternary: error no-new-object: error - no-tabs: error - no-trailing-spaces: error no-underscore-dangle: - error - allowAfterThis: true no-unneeded-ternary: error - no-whitespace-before-property: error - object-curly-newline: error - object-curly-spacing: - - error - - always - object-property-newline: - - error - - allowMultiplePropertiesPerLine: true one-var: - error - never operator-assignment: error - operator-linebreak: error - padded-blocks: - - error - - never padding-line-between-statements: error - quote-props: - - error - - as-needed - quotes: - - error - - single - semi: - - error - - always - semi-spacing: error - semi-style: error sort-vars: error - space-before-blocks: error - space-before-function-paren: - - error - - named: never - space-in-parens: error - space-infix-ops: error - space-unary-ops: error - # spaced-comment: error - switch-colon-spacing: error - template-tag-spacing: error - unicode-bom: error - wrap-regex: error + spaced-comment: error ## ECMAScript 6 arrow-body-style: error - arrow-parens: - - error - - as-needed - arrow-spacing: error - generator-star-spacing: error no-duplicate-imports: error no-restricted-imports: error no-useless-computed-key: error @@ -236,8 +156,5 @@ rules: prefer-numeric-literals: error prefer-spread: error prefer-template: error - rest-spread-spacing: error sort-imports: error symbol-description: error - template-curly-spacing: error - yield-star-spacing: error diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..404abb2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +coverage/ diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..43cc67e --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,2 @@ +singleQuote: true +trailingComma: es5 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index e643083..328aa2a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,21 +14,21 @@ orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/README.md b/README.md index 5cbab3e..addb459 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ release of this plugin. I apologize for the inconvenience in the meantime.** You can then use this plugin as any other Chai plugins: + ```js const chai = require('chai'); const chaiImmutable = require('chai-immutable'); @@ -54,6 +55,7 @@ chai.use(chaiImmutable); ### ES6 syntax (needs Babel transpiling) + ```js import chai from 'chai'; import chaiImmutable from 'chai-immutable'; @@ -78,6 +80,7 @@ If you are using this plugin with `chai-immutable` must be loaded **before** any of them. For example: + ```js const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); @@ -110,7 +113,7 @@ expect(List.of(1, 2, 3)).to.not.be.empty; ### .equal(collection) -- **@param** *{ Collection }* collection +- **@param** _{ Collection }_ collection Asserts that the values of the target are equivalent to the values of `collection`. Aliases of Chai's original `equal` method are also supported. @@ -133,7 +136,7 @@ tested against immutable data structures, therefore they are aliases to ### .include(value) -- **@param** *{ Mixed }* val +- **@param** _{ Mixed }_ val The `include` and `contain` assertions can be used as either property based language chains or as methods to assert the inclusion of a value @@ -151,7 +154,7 @@ expect(new Map({ foo: 'bar', hello: 'world' })).to.include.keys('foo'); ### .keys(key1[, key2[, ...]]) -- **@param** *{ String... | Array | Object | Collection }* key*N* +- **@param** _{ String... | Array | Object | Collection }_ key*N* Asserts that the target collection has the given keys. @@ -172,7 +175,9 @@ expect(new List(['x', 'y'])).to.have.all.keys([0, 1]); // Values in the passed object are ignored: expect(new Map({ foo: 1, bar: 2 })).to.have.all.keys({ bar: 6, foo: 7 }); -expect(new Map({ foo: 1, bar: 2 })).to.have.all.keys(new Map({ bar: 6, foo: 7 })); +expect(new Map({ foo: 1, bar: 2 })).to.have.all.keys( + new Map({ bar: 6, foo: 7 }) +); expect(new List(['x', 'y'])).to.have.all.keys({ 0: 4, 1: 5 }); ``` @@ -191,11 +196,11 @@ uncertain expectations. ```js // Recommended; asserts that target doesn't have any of the given keys -expect(new Map({a: 1, b: 2})).to.not.have.any.keys('c', 'd'); +expect(new Map({ a: 1, b: 2 })).to.not.have.any.keys('c', 'd'); // Not recommended; asserts that target doesn't have all of the given // keys but may or may not have some of them -expect(new Map({a: 1, b: 2})).to.not.have.all.keys('c', 'd'); +expect(new Map({ a: 1, b: 2 })).to.not.have.all.keys('c', 'd'); ``` When asserting `.keys` without negation, `.all` is preferred because @@ -204,11 +209,11 @@ When asserting `.keys` without negation, `.all` is preferred because ```js // Recommended; asserts that target has all the given keys -expect(new Map({a: 1, b: 2})).to.have.all.keys('a', 'b'); +expect(new Map({ a: 1, b: 2 })).to.have.all.keys('a', 'b'); // Not recommended; asserts that target has at least one of the given // keys but may or may not have more of them -expect(new Map({a: 1, b: 2})).to.have.any.keys('a', 'b'); +expect(new Map({ a: 1, b: 2 })).to.have.any.keys('a', 'b'); ``` Note that `.all` is used by default when neither `.all` nor `.any` appear @@ -217,8 +222,8 @@ it improves readability. ```js // Both assertions are identical -expect(new Map({a: 1, b: 2})).to.have.all.keys('a', 'b'); // Recommended -expect(new Map({a: 1, b: 2})).to.have.keys('a', 'b'); // Not recommended +expect(new Map({ a: 1, b: 2 })).to.have.all.keys('a', 'b'); // Recommended +expect(new Map({ a: 1, b: 2 })).to.have.keys('a', 'b'); // Not recommended ``` Add `.include` earlier in the chain to require that the target's keys be a @@ -226,8 +231,8 @@ superset of the expected keys, rather than identical sets. ```js // Target object's keys are a superset of ['a', 'b'] but not identical -expect(new Map({a: 1, b: 2, c: 3})).to.include.all.keys('a', 'b'); -expect(new Map({a: 1, b: 2, c: 3})).to.not.have.all.keys('a', 'b'); +expect(new Map({ a: 1, b: 2, c: 3 })).to.include.all.keys('a', 'b'); +expect(new Map({ a: 1, b: 2, c: 3 })).to.not.have.all.keys('a', 'b'); ``` However, if `.any` and `.include` are combined, only the `.any` takes @@ -235,8 +240,8 @@ effect. The `.include` is ignored in this case. ```js // Both assertions are identical -expect(new Map({a: 1})).to.have.any.keys('a', 'b'); -expect(new Map({a: 1})).to.include.any.keys('a', 'b'); +expect(new Map({ a: 1 })).to.have.any.keys('a', 'b'); +expect(new Map({ a: 1 })).to.include.any.keys('a', 'b'); ``` The alias `.key` can be used interchangeably with `.keys`. @@ -247,20 +252,20 @@ expect(new Map({ foo: 1 })).to.have.key('foo'); ### .property(path[, val]) -- **@param** *{ String | Array | Iterable }* path -- **@param** *{ Mixed }* val (optional) +- **@param** _{ String | Array | Iterable }_ path +- **@param** _{ Mixed }_ val (optional) Asserts that the target has a property with the given `path`. ```js -expect(new Map({a: 1})).to.have.property('a'); +expect(new Map({ a: 1 })).to.have.property('a'); ``` When `val` is provided, `.property` also asserts that the property's value is equal to the given `val`. `val` can be an immutable collection. ```js -expect(new Map({a: 1})).to.have.property('a', 1); +expect(new Map({ a: 1 })).to.have.property('a', 1); ``` Note that `deep.property` behaves exactly like `property` in the context of @@ -271,23 +276,36 @@ referencing nested properties. An immutable `List` can also be used as the starting point of a `nested.property`. ```js -expect(Immutable.fromJS({a: {b: ['x', 'y']}})).to.have.nested.property('a.b[1]'); -expect(Immutable.fromJS({a: {b: ['x', 'y']}})).to.have.nested.property('a.b[1]', 'y'); -expect(Immutable.fromJS({a: {b: ['x', 'y']}})).to.have.nested.property(['a', 'b', 1], 'y'); -expect(Immutable.fromJS({a: {b: ['x', 'y']}})).to.have.nested.property(new List(['a', 'b', 1]), 'y'); +expect(Immutable.fromJS({ a: { b: ['x', 'y'] } })).to.have.nested.property( + 'a.b[1]' +); +expect(Immutable.fromJS({ a: { b: ['x', 'y'] } })).to.have.nested.property( + 'a.b[1]', + 'y' +); +expect(Immutable.fromJS({ a: { b: ['x', 'y'] } })).to.have.nested.property( + ['a', 'b', 1], + 'y' +); +expect(Immutable.fromJS({ a: { b: ['x', 'y'] } })).to.have.nested.property( + new List(['a', 'b', 1]), + 'y' +); ``` If `.` or `[]` are part of an actual property name, they can be escaped by adding two backslashes before them. ```js -expect(Immutable.fromJS({'.a': {'[b]': 'x'}})).to.have.nested.property('\\.a.\\[b\\]'); +expect(Immutable.fromJS({ '.a': { '[b]': 'x' } })).to.have.nested.property( + '\\.a.\\[b\\]' +); ``` Add `.not` earlier in the chain to negate `.property`. ```js -expect(new Map({a: 1})).to.not.have.property('b'); +expect(new Map({ a: 1 })).to.not.have.property('b'); ``` However, it's dangerous to negate `.property` when providing `val`. The @@ -301,8 +319,8 @@ When the target isn't expected to have a property at the given `path`, it's often best to assert exactly that. ```js -expect(new Map({b: 2})).to.not.have.property('a'); // Recommended -expect(new Map({b: 2})).to.not.have.property('a', 1); // Not recommended +expect(new Map({ b: 2 })).to.not.have.property('a'); // Recommended +expect(new Map({ b: 2 })).to.not.have.property('a', 1); // Not recommended ``` When the target is expected to have a property at the given key `path`, @@ -310,20 +328,22 @@ it's often best to assert that the property has its expected value, rather than asserting that it doesn't have one of many unexpected values. ```js -expect(new Map({a: 3})).to.have.property('a', 3); // Recommended -expect(new Map({a: 3})).to.not.have.property('a', 1); // Not recommended +expect(new Map({ a: 3 })).to.have.property('a', 3); // Recommended +expect(new Map({ a: 3 })).to.not.have.property('a', 1); // Not recommended ``` `.property` changes the target of any assertions that follow in the chain to be the value of the property from the original target object. ```js -expect(new Map({a: 1})).to.have.property('a').that.is.a('number'); +expect(new Map({ a: 1 })) + .to.have.property('a') + .that.is.a('number'); ``` ### .size(value) -- **@param** *{ Number }* size +- **@param** _{ Number }_ size Asserts that the immutable collection has the expected size. @@ -339,7 +359,7 @@ expect(List.of(1, 2, 3)).to.have.size.least(3); expect(List.of(1, 2, 3)).to.have.size.most(3); expect(List.of(1, 2, 3)).to.have.size.above(2); expect(List.of(1, 2, 3)).to.have.size.below(4); -expect(List.of(1, 2, 3)).to.have.size.within(2,4); +expect(List.of(1, 2, 3)).to.have.size.within(2, 4); ``` Similarly to `length`/`lengthOf`, `sizeOf` is an alias of `size`: @@ -352,8 +372,8 @@ expect(List.of(1, 2, 3)).to.have.sizeOf(3); ### .equal(actual, expected) -- **@param** *{ Collection }* actual -- **@param** *{ Collection }* expected +- **@param** _{ Collection }_ actual +- **@param** _{ Collection }_ expected Asserts that the values of `actual` are equivalent to the values of `expected`. Note that `.strictEqual()` and `.deepEqual()` assert @@ -373,8 +393,8 @@ more information. ### .notEqual(actual, expected) -- **@param** *{ Collection }* actual -- **@param** *{ Collection }* expected +- **@param** _{ Collection }_ actual +- **@param** _{ Collection }_ expected Asserts that the values of `actual` are not equivalent to the values of `expected`. Note that `.notStrictEqual()` and `.notDeepEqual()` assert @@ -388,8 +408,8 @@ assert.notEqual(a, b); ### .sizeOf(collection, length) -- **@param** *{ Collection }* collection -- **@param** *{ Number }* size +- **@param** _{ Collection }_ collection +- **@param** _{ Number }_ size Asserts that the immutable collection has the expected size. diff --git a/chai-immutable.js b/chai-immutable.js index eeeda7b..885cca2 100644 --- a/chai-immutable.js +++ b/chai-immutable.js @@ -1,9 +1,11 @@ 'use strict'; ((context, factory) => { - if (typeof require === 'function' && - typeof exports === 'object' && - typeof module === 'object') { + if ( + typeof require === 'function' && + typeof exports === 'object' && + typeof module === 'object' + ) { // Node.js module.exports = factory(require('immutable')); } else { @@ -39,22 +41,26 @@ * @api public */ - Assertion.overwriteProperty('empty', _super => function () { - const obj = this._obj; + Assertion.overwriteProperty( + 'empty', + _super => + function() { + const obj = this._obj; - if (Immutable.Iterable.isIterable(obj)) { - const { size } = obj; - new Assertion(size).a('number'); + if (Immutable.Iterable.isIterable(obj)) { + const { size } = obj; + new Assertion(size).a('number'); - this.assert( - size === 0, - 'expected #{this} to be empty but got size #{act}', - 'expected #{this} to not be empty' - ); - } else { - _super.apply(this, arguments); - } - }); + this.assert( + size === 0, + 'expected #{this} to be empty but got size #{act}', + 'expected #{this} to not be empty' + ); + } else { + _super.apply(this, arguments); + } + } + ); /** * ### .equal(collection) @@ -90,7 +96,7 @@ */ function assertCollectionEqual(_super) { - return function (collection) { + return function(collection) { const obj = this._obj; if (Immutable.Iterable.isIterable(obj)) { @@ -141,7 +147,7 @@ */ function assertCollectionInclude(_super) { - return function (val) { + return function(val) { const obj = this._obj; if (Immutable.Iterable.isIterable(obj)) { @@ -159,7 +165,7 @@ } function chainCollectionInclude(_super) { - return function () { + return function() { _super.apply(this, arguments); }; } @@ -276,7 +282,7 @@ */ function assertKeyedCollectionKeys(_super) { - return function (keys) { + return function(keys) { const obj = this._obj; if (Immutable.Iterable.isIterable(obj)) { @@ -291,13 +297,13 @@ } else { keys = Object.keys(keys); } - // `keys` is now an array so this statement safely falls through + // `keys` is now an array so this statement safely falls through case 'Array': if (arguments.length > 1) { throw new chai.AssertionError( 'when testing keys against an immutable collection, you must ' + - 'give a single Array|Object|String|Collection argument or ' + - 'multiple String arguments', + 'give a single Array|Object|String|Collection argument or ' + + 'multiple String arguments', null, ssfi ); @@ -309,7 +315,7 @@ } // Only stringify non-Symbols because Symbols would become "Symbol()" - keys = keys.map(val => typeof val === 'symbol' ? val : String(val)); + keys = keys.map(val => (typeof val === 'symbol' ? val : String(val))); if (!keys.length) { throw new chai.AssertionError('keys required', null, ssfi); @@ -361,7 +367,7 @@ Assertion.overwriteMethod('keys', assertKeyedCollectionKeys); Assertion.overwriteMethod('key', assertKeyedCollectionKeys); - /*! + /** * ## parsePath(path) * * Helper function used to parse string paths into arrays of keys and @@ -384,7 +390,8 @@ * @returns {Array} parsed * @api private */ - function parsePath(path) { // Given the following path: 'a.b[1]' + function parsePath(path) { + // Given the following path: 'a.b[1]' // Separates keys followed by indices with a dot: 'a.b.[1]' const str = path.replace(/([^\\])\[/g, '$1.['); // Extracts all indices and keys into an array: ['a', 'b', '[1]'] @@ -492,7 +499,7 @@ */ function assertProperty(_super) { - return function (path, val) { + return function(path, val) { const obj = this._obj; if (Immutable.Iterable.isIterable(obj)) { @@ -620,7 +627,7 @@ // Numerical comparator overwrites function assertCollectionSizeLeast(_super) { - return function (n) { + return function(n) { if (utils.flag(this, 'immutable.collection.size')) { assertIsIterable(this._obj); @@ -642,7 +649,7 @@ } function assertCollectionSizeMost(_super) { - return function (n) { + return function(n) { if (utils.flag(this, 'immutable.collection.size')) { assertIsIterable(this._obj); @@ -664,7 +671,7 @@ } function assertCollectionSizeAbove(_super) { - return function (n) { + return function(n) { if (utils.flag(this, 'immutable.collection.size')) { assertIsIterable(this._obj); @@ -685,7 +692,7 @@ } function assertCollectionSizeBelow(_super) { - return function (n) { + return function(n) { if (utils.flag(this, 'immutable.collection.size')) { assertIsIterable(this._obj); @@ -719,24 +726,28 @@ Assertion.overwriteMethod('lt', assertCollectionSizeBelow); Assertion.overwriteMethod('lessThan', assertCollectionSizeBelow); - Assertion.overwriteMethod('within', _super => function (min, max) { - if (utils.flag(this, 'immutable.collection.size')) { - assertIsIterable(this._obj); + Assertion.overwriteMethod( + 'within', + _super => + function(min, max) { + if (utils.flag(this, 'immutable.collection.size')) { + assertIsIterable(this._obj); - const { size } = this._obj; - new Assertion(size).a('number'); + const { size } = this._obj; + new Assertion(size).a('number'); - this.assert( - min <= size && size <= max, - 'expected #{this} to have a size within #{exp} but got #{act}', - 'expected #{this} to not have a size within #{exp} but got #{act}', - `${min}..${max}`, - size - ); - } else { - _super.apply(this, arguments); - } - }); + this.assert( + min <= size && size <= max, + 'expected #{this} to have a size within #{exp} but got #{act}', + 'expected #{this} to not have a size within #{exp} but got #{act}', + `${min}..${max}`, + size + ); + } else { + _super.apply(this, arguments); + } + } + ); /** * ## TDD API Reference diff --git a/package.json b/package.json index 3d6661b..50a87b4 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,15 @@ "test": "test" }, "scripts": { - "lint": "eslint --ignore-path .gitignore . --report-unused-disable-directives", - "test": "run-s --continue-on-error test:* lint", + "format": "run-s -c \"lint:eslint --fix\" \"lint:prettier --write\"", + "lint:eslint": "eslint --ignore-path .gitignore . --report-unused-disable-directives", + "lint:prettier": "prettier --list-different \"**/*.{js,md}\"", + "test": "run-s -c test:* lint:* eslint-check:*", "test:readme": "mocha --compilers md:fulky/md-compiler README.md", "test:mocha": "nyc mocha", - "coveralls": "nyc report --reporter=text-lcov | coveralls" + "coveralls": "nyc report --reporter=text-lcov | coveralls", + "eslint-check:main": "eslint --print-config .eslintrc.yml | eslint-config-prettier-check", + "eslint-check:test": "eslint --print-config test/.eslintrc.yml | eslint-config-prettier-check" }, "repository": { "type": "git", @@ -45,6 +49,7 @@ "chai": "4.1.2", "coveralls": "3.0.1", "eslint": "4.19.1", + "eslint-config-prettier": "2.9.0", "eslint-plugin-chai-expect": "1.1.1", "eslint-plugin-chai-friendly": "0.4.1", "eslint-plugin-mocha": "5.0.0", @@ -52,6 +57,7 @@ "immutable": "3.8.2", "mocha": "5.2.0", "npm-run-all": "4.1.3", - "nyc": "11.8.0" + "nyc": "11.8.0", + "prettier": "1.13.0" } } diff --git a/test/.eslintrc.yml b/test/.eslintrc.yml index cae7e10..0a5f088 100644 --- a/test/.eslintrc.yml +++ b/test/.eslintrc.yml @@ -10,10 +10,9 @@ plugins: # Override from root `.eslintrc.yml` rules: - max-len: - - error - - tabWidth: 2 - ignorePattern: (describe|it)\('.*', function \(\) \{ + # Until estlint-plugin-mocha has a Mocha-aware prefer-arrow-callback (see + # below), disabling this rule + prefer-arrow-callback: off ## eslint-plugin-chai-expect ## https://github.com/Turbo87/eslint-plugin-chai-expect diff --git a/test/test.js b/test/test.js index 42a94a2..7c9d28a 100644 --- a/test/test.js +++ b/test/test.js @@ -30,14 +30,9 @@ if (!chai) { const clonedImmutable = clone(Immutable); const { assert, expect } = chai; -const { - List, - Map, - Set, - Stack, -} = Immutable; - -/*! +const { List, Map, Set, Stack } = Immutable; + +/** * Test helper to check that a given function (wrapping the assertion) will * fail. */ @@ -49,52 +44,52 @@ function fail(fn, msg) { } } -describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-callback +describe('chai-immutable', function() { const list3 = List.of(1, 2, 3); const deepMap = new Map({ foo: 'bar', list: List.of(1, 2, 3) }); const sameDeepMap = new Map({ foo: 'bar', list: List.of(1, 2, 3) }); const differentDeepMap = new Map({ foo: 'bar', list: List.of(42) }); const clonedImmutableList = clonedImmutable.List.of(1, 2, 3); - describe('BDD interface', function () { // eslint-disable-line prefer-arrow-callback - describe('empty property', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given an empty collection', function () { // eslint-disable-line prefer-arrow-callback + describe('BDD interface', function() { + describe('empty property', function() { + it('should pass given an empty collection', function() { expect(new List()).to.be.empty; }); - it('should pass using `not` given a non-empty collection', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given a non-empty collection', function() { expect(list3).to.not.be.empty; }); - it('should not affect the original assertions', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions', function() { expect([]).to.be.empty; expect('').to.be.empty; expect({}).to.be.empty; }); - it('should fail given a non-empty collection', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given a non-empty collection', function() { fail(() => expect(list3).to.be.empty); }); - it('should fail using `not` given an empty collection', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given an empty collection', function() { fail(() => expect(new List()).to.not.be.empty); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { expect(new clonedImmutable.List()).to.be.empty; }); }); - describe('equal method', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given equal values', function () { // eslint-disable-line prefer-arrow-callback + describe('equal method', function() { + it('should pass given equal values', function() { expect(list3).to.equal(List.of(1, 2, 3)); }); - it('should pass using `not` given different values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given different values', function() { expect(list3).to.not.equal(new List()); }); - it('aliases of equal should also work', function () { // eslint-disable-line prefer-arrow-callback + it('aliases of equal should also work', function() { expect(list3).to.equal(List.of(1, 2, 3)); expect(list3).to.not.equal(new List()); expect(list3).to.equals(List.of(1, 2, 3)); @@ -109,7 +104,7 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal expect(list3).to.not.deep.equal(new List()); }); - it('should not affect the original assertions', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions', function() { expect('hello').to.equal('hello'); expect(42).to.equal(42); expect(1).to.not.equal(true); @@ -117,7 +112,7 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' }); }); - it('should pass given deeply equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given deeply equal values', function() { expect(deepMap).to.equal(sameDeepMap); expect(deepMap).to.equals(sameDeepMap); expect(deepMap).to.eq(sameDeepMap); @@ -126,7 +121,7 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal expect(deepMap).to.deep.equal(sameDeepMap); }); - it('should pass using `not` given deeply different values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given deeply different values', function() { expect(deepMap).to.not.equal(differentDeepMap); expect(deepMap).to.not.equals(differentDeepMap); expect(deepMap).to.not.eq(differentDeepMap); @@ -135,12 +130,12 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal expect(deepMap).to.not.deep.equal(differentDeepMap); }); - it('should pass using `not` given a non-Immutable value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given a non-Immutable value', function() { expect([]).to.not.equal(new List()); }); // See https://github.com/astorije/chai-immutable/issues/7 - it('should display a helpful failure output on big objects', function () { // eslint-disable-line prefer-arrow-callback + it('should display a helpful failure output on big objects', function() { const actual = new Map({ foo: 'foo foo foo foo foo foo foo foo' }); const expected = new Map({ bar: 'bar bar bar bar bar bar bar bar' }); // AssertionError: expected { Object (foo) } to equal { Object (bar) } @@ -156,19 +151,19 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal ); }); - it('should fail given a non-Immutable value', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given a non-Immutable value', function() { fail(() => expect([]).to.equal(new List())); }); - it('should fail given different values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given different values', function() { fail(() => expect(list3).to.equal(new List())); }); - it('should fail using `not` given equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given equal values', function() { fail(() => expect(list3).to.not.equal(List.of(1, 2, 3))); }); - it('should fail given deeply different values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given deeply different values', function() { fail(() => expect(deepMap).to.equal(differentDeepMap)); fail(() => expect(deepMap).to.equals(differentDeepMap)); fail(() => expect(deepMap).to.eq(differentDeepMap)); @@ -177,7 +172,7 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal fail(() => expect(deepMap).to.deep.equal(differentDeepMap)); }); - it('should fail using `not` given deeply equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given deeply equal values', function() { fail(() => expect(deepMap).to.not.equal(sameDeepMap)); fail(() => expect(deepMap).to.not.equals(sameDeepMap)); fail(() => expect(deepMap).to.not.eq(sameDeepMap)); @@ -186,36 +181,39 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal fail(() => expect(deepMap).to.not.deep.equal(sameDeepMap)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { expect(clonedImmutableList).to.equal(List.of(1, 2, 3)); }); }); - describe('include method', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given an existing value', function () { // eslint-disable-line prefer-arrow-callback + describe('include method', function() { + it('should pass given an existing value', function() { expect(new List([1, 2, 3])).to.include(2); expect(new List([1, 2, 3])).to.deep.include(2); }); - it('should pass using `not` given an inexisting value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given an inexisting value', function() { expect(new List([1, 2, 3])).to.not.include(42); expect(new List([1, 2, 3])).to.not.deep.include(42); }); - it('should chain and pass given an existing key', function () { // eslint-disable-line prefer-arrow-callback + it('should chain and pass given an existing key', function() { expect(new Map({ foo: 'bar', hello: 'world' })).to.include.keys('foo'); - expect(new Map({ foo: 'bar', hello: 'world' })) - .to.deep.include.keys('foo'); + expect(new Map({ foo: 'bar', hello: 'world' })).to.deep.include.keys( + 'foo' + ); }); - it('should chain and pass using `not` given an inexisting key', function () { // eslint-disable-line prefer-arrow-callback - expect(new Map({ foo: 'bar', hello: 'world' })) - .to.not.include.keys('not-foo'); - expect(new Map({ foo: 'bar', hello: 'world' })) - .to.not.deep.include.keys('not-foo'); + it('should chain and pass using `not` given an inexisting key', function() { + expect(new Map({ foo: 'bar', hello: 'world' })).to.not.include.keys( + 'not-foo' + ); + expect( + new Map({ foo: 'bar', hello: 'world' }) + ).to.not.deep.include.keys('not-foo'); }); - it('aliases of include should also work', function () { // eslint-disable-line prefer-arrow-callback + it('aliases of include should also work', function() { expect(new List([1, 2, 3])).contain(2); expect(new List([1, 2, 3])).not.contain(42); expect(new List([1, 2, 3])).contains(2); @@ -224,7 +222,7 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal expect(new List([1, 2, 3])).not.includes(42); }); - it('should not affect the original assertions', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions', function() { expect([1, 2, 3]).to.include(2); expect([1, 2, 3]).to.deep.include(2); expect('foobar').to.contain('foo'); @@ -234,100 +232,107 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal }); // See https://github.com/astorije/chai-immutable/issues/7 - it('should display a helpful failure output on big objects', function () { // eslint-disable-line prefer-arrow-callback + it('should display a helpful failure output on big objects', function() { const lengthyMap = new Map({ foo: 'foo foo foo foo foo foo foo foo ' }); - fail( - () => expect(lengthyMap).to.include('not-foo'), - /(foo ){8}/ - ); - fail( - () => expect(lengthyMap).to.deep.include('not-foo'), - /(foo ){8}/ - ); + fail(() => expect(lengthyMap).to.include('not-foo'), /(foo ){8}/); + fail(() => expect(lengthyMap).to.deep.include('not-foo'), /(foo ){8}/); }); - it('should fail given an inexisting value', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given an inexisting value', function() { fail(() => expect(new List([1, 2, 3])).to.include(42)); fail(() => expect(new List([1, 2, 3])).to.deep.include(42)); }); - it('should fail using `not` given an existing value', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given an existing value', function() { fail(() => expect(new List([1, 2, 3])).not.to.include(2)); fail(() => expect(new List([1, 2, 3])).not.to.deep.include(2)); }); - it('should chain and fail given an inexisting key', function () { // eslint-disable-line prefer-arrow-callback - fail(() => expect(new Map({ foo: 'bar', hello: 'world' })) - .to.include.keys('not-foo')); - fail(() => expect(new Map({ foo: 'bar', hello: 'world' })) - .to.deep.include.keys('not-foo')); + it('should chain and fail given an inexisting key', function() { + fail(() => + expect(new Map({ foo: 'bar', hello: 'world' })).to.include.keys( + 'not-foo' + ) + ); + fail(() => + expect(new Map({ foo: 'bar', hello: 'world' })).to.deep.include.keys( + 'not-foo' + ) + ); }); - it('should chain and fail using `not` given an existing key', function () { // eslint-disable-line prefer-arrow-callback - fail(() => expect(new Map({ foo: 'bar', hello: 'world' })) - .to.not.include.keys('foo')); - fail(() => expect(new Map({ foo: 'bar', hello: 'world' })) - .to.not.deep.include.keys('foo')); + it('should chain and fail using `not` given an existing key', function() { + fail(() => + expect(new Map({ foo: 'bar', hello: 'world' })).to.not.include.keys( + 'foo' + ) + ); + fail(() => + expect( + new Map({ foo: 'bar', hello: 'world' }) + ).to.not.deep.include.keys('foo') + ); }); }); - describe('keys method', function () { // eslint-disable-line prefer-arrow-callback + describe('keys method', function() { const obj = { x: 1, y: 2 }; const map = new Map(obj); - it('should pass given an existing key', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given an existing key', function() { expect(new Map({ x: 1 })).to.have.key('x'); expect(new Map({ x: 1 })).to.have.deep.key('x'); }); - it('should pass using `not` given an inexisting key', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given an inexisting key', function() { expect(map).to.not.have.key('z'); expect(map).to.not.have.deep.key('z'); }); - it('should pass given multiple existing keys', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given multiple existing keys', function() { expect(map).to.have.keys('x', 'y'); expect(map).to.have.deep.keys('x', 'y'); }); - it('should pass using `not` given multiple inexisting keys', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given multiple inexisting keys', function() { expect(map).to.not.have.keys('z1', 'z2'); expect(map).to.not.have.deep.keys('z1', 'z2'); }); - it('should accept an Array of keys to check against', function () { // eslint-disable-line prefer-arrow-callback + it('should accept an Array of keys to check against', function() { expect(map).to.have.keys(['x', 'y']); expect(map).to.have.deep.keys(['x', 'y']); }); - it('should accept a List of keys to check against', function () { // eslint-disable-line prefer-arrow-callback + it('should accept a List of keys to check against', function() { expect(map).to.have.keys(new List(['x', 'y'])); expect(map).to.have.deep.keys(new List(['x', 'y'])); }); - it('should accept a Set of keys to check against', function () { // eslint-disable-line prefer-arrow-callback + it('should accept a Set of keys to check against', function() { expect(map).to.have.keys(new Set(['x', 'y'])); expect(map).to.have.deep.keys(new Set(['x', 'y'])); }); - it('should accept a Stack of keys to check against', function () { // eslint-disable-line prefer-arrow-callback + it('should accept a Stack of keys to check against', function() { expect(map).to.have.keys(new Stack(['x', 'y'])); expect(map).to.have.deep.keys(new Stack(['x', 'y'])); }); - it('should accept an Object to check against', function () { // eslint-disable-line prefer-arrow-callback + it('should accept an Object to check against', function() { expect(map).to.have.keys({ x: 6, y: 7 }); expect(map).to.have.deep.keys({ x: 6, y: 7 }); expect(new List(['x', 'y'])).to.have.all.keys({ 0: 4, 1: 5 }); }); - it('should accept a Map to check against', function () { // eslint-disable-line prefer-arrow-callback + it('should accept a Map to check against', function() { expect(map).to.have.keys(new Map({ x: 6, y: 7 })); expect(map).to.have.deep.keys(new Map({ x: 6, y: 7 })); }); - it('should error when given multiple non-scalar arguments', function () { // eslint-disable-line prefer-arrow-callback - const msg = 'when testing keys against an immutable collection, ' + + it('should error when given multiple non-scalar arguments', function() { + const msg = + 'when testing keys against an immutable collection, ' + 'you must give a single Array|Object|String|Collection argument or ' + 'multiple String arguments'; @@ -339,7 +344,7 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal fail(() => expect(map).to.have.all.keys(new Map({ x: 1 }), 'y'), msg); }); - it('should error when given no arguments', function () { // eslint-disable-line prefer-arrow-callback + it('should error when given no arguments', function() { const msg = 'keys required'; fail(() => expect(map).to.have.all.keys([]), msg); @@ -350,32 +355,32 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal fail(() => expect(map).to.have.all.keys(new Map()), msg); }); - it('should pass using `any` given an existing key', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `any` given an existing key', function() { expect(map).to.have.any.keys('x', 'z'); expect(map).to.have.any.deep.keys('x', 'z'); }); - it('should pass using `not` and `any` given inexisting keys', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` and `any` given inexisting keys', function() { expect(map).to.not.have.any.keys('z1', 'z2'); expect(map).to.not.have.any.deep.keys('z1', 'z2'); }); - it('should pass using `all` given existing keys', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `all` given existing keys', function() { expect(map).to.have.all.keys('x', 'y'); expect(map).to.have.all.deep.keys('x', 'y'); }); - it('should pass using `not` and `all` given inexisting keys', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` and `all` given inexisting keys', function() { expect(map).to.not.have.all.keys('z1', 'y'); expect(map).to.not.have.all.deep.keys('z1', 'y'); }); - it('should pass using `contain` given an existing key', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `contain` given an existing key', function() { expect(map).to.contain.key('x'); expect(map).to.contain.deep.key('x'); }); - it('should not affect the original assertions', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions', function() { expect({ x: 1, y: 2 }).to.have.any.keys('x', 'z'); expect({ x: 1, y: 2 }).to.have.any.deep.keys('x', 'z'); expect({ x: 1, y: 2 }).to.have.any.keys('x'); @@ -397,13 +402,10 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal }); // See https://github.com/astorije/chai-immutable/issues/7 - it('should display a helpful failure output on big objects', function () { // eslint-disable-line prefer-arrow-callback + it('should display a helpful failure output on big objects', function() { const lengthyMap = new Map({ foo: 'foo foo foo foo foo foo foo foo ' }); - fail( - () => expect(lengthyMap).to.have.keys('not-foo'), - /(foo ){8}/ - ); + fail(() => expect(lengthyMap).to.have.keys('not-foo'), /(foo ){8}/); fail( () => expect(lengthyMap).to.have.deep.keys('not-foo'), @@ -411,65 +413,65 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal ); }); - it('should pass against Lists', function () { // eslint-disable-line prefer-arrow-callback + it('should pass against Lists', function() { expect(new List(['x', 'y'])).to.have.all.keys(0, 1); expect(new List(['x', 'y'])).to.have.all.keys([0, 1]); }); - it('should fail given an inexisting key', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given an inexisting key', function() { fail(() => expect(new Map({ x: 1 })).to.have.key('z')); fail(() => expect(new Map({ x: 1 })).to.have.deep.key('z')); fail(() => expect({ x: 1 }).to.have.key('z')); fail(() => expect({ x: 1 }).to.have.deep.key('z')); }); - it('should fail given multiple inexisting keys', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given multiple inexisting keys', function() { fail(() => expect(map).to.have.keys('z1', 'z2')); fail(() => expect(map).to.have.deep.keys('z1', 'z2')); }); - it('should fail using `not` given multiple existing keys', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given multiple existing keys', function() { fail(() => expect(map).to.not.have.keys('x', 'y')); fail(() => expect(map).to.not.have.deep.keys('x', 'y')); }); - it('should fail using `any` given inexisting keys', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `any` given inexisting keys', function() { fail(() => expect(map).to.have.any.keys('z1', 'z2')); fail(() => expect(map).to.have.any.deep.keys('z1', 'z2')); }); - it('should fail using `not` and `any` given an existing key', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` and `any` given an existing key', function() { fail(() => expect(map).to.not.have.any.keys('x', 'z')); fail(() => expect(map).to.not.have.any.deep.keys('x', 'z')); }); - it('should fail using `all` given an inexisting key', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `all` given an inexisting key', function() { fail(() => expect(map).to.have.all.keys('z1', 'y')); fail(() => expect(map).to.have.all.deep.keys('z1', 'y')); }); - it('should fail using `not` and `all` given existing keys', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` and `all` given existing keys', function() { fail(() => expect(map).to.not.have.all.keys('x', 'y')); fail(() => expect(map).to.not.have.all.deep.keys('x', 'y')); }); - it('should fail using `contain` given an inexisting key', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `contain` given an inexisting key', function() { fail(() => expect(map).to.contain.key('z')); fail(() => expect(map).to.contain.deep.key('z')); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { expect(new clonedImmutable.Map({ x: 1 })).to.have.key('x'); expect(new clonedImmutable.Map({ x: 1 })).to.have.deep.key('x'); }); }); - describe('property property', function () { // eslint-disable-line prefer-arrow-callback - it('should not affect the original assertion', function () { // eslint-disable-line prefer-arrow-callback + describe('property property', function() { + it('should not affect the original assertion', function() { expect({ x: 1 }).to.have.property('x', 1); }); - it('should not affect the original assertion using `not`', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertion using `not`', function() { expect({ x: 1 }).not.to.have.property('z'); expect({ x: 1 }).not.to.have.property('z', 42); }); @@ -480,383 +482,422 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal const obj = Immutable.fromJS({ x: 1 }); const nestedObj = Immutable.fromJS({ x: 1, y: { x: 2, y: 3 } }); - it('should fail given an inexisting property', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given an inexisting property', function() { fail(() => expect(obj).to.have.property('z')); fail(() => expect(obj).to.have.deep.property('z')); }); - it('should pass using `not` given an inexisting property', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given an inexisting property', function() { expect(obj).not.to.have.property('z'); expect(obj).not.to.have.deep.property('z'); }); - it('should pass using `not` given an inexisting property and value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given an inexisting property and value', function() { expect(obj).not.to.have.property('z', 42); expect(obj).not.to.have.deep.property('z', 42); }); - it('should pass given an existing property', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given an existing property', function() { expect(obj).to.have.property('x'); expect(obj).to.have.deep.property('x'); }); - it('should fail using `not` given an existing property', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given an existing property', function() { fail(() => expect(obj).not.to.have.property('x')); fail(() => expect(obj).not.to.have.deep.property('x')); }); - it('should fail given a property with a bad value', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given a property with a bad value', function() { fail(() => expect(obj).to.have.property('x', 'different')); fail(() => expect(obj).to.have.deep.property('x', 'different')); }); - it('should pass given a property with the good value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given a property with the good value', function() { expect(obj).to.have.property('x', 1); expect(obj).to.have.deep.property('x', 1); }); - it('should pass given an immutable value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given an immutable value', function() { const obj2 = Immutable.fromJS({ foo: { bar: 42 } }); expect(obj2).to.have.property('foo', new Map({ bar: 42 })); expect(obj2).to.have.deep.property('foo', new Map({ bar: 42 })); }); - it('should change the subject to the value of that property', function () { // eslint-disable-line prefer-arrow-callback + it('should change the subject to the value of that property', function() { const sub = nestedObj.get('y'); - expect(nestedObj).to.have.property('y').that.equal(sub); - expect(nestedObj).to.have.deep.property('y').that.equal(sub); + expect(nestedObj) + .to.have.property('y') + .that.equal(sub); + expect(nestedObj) + .to.have.deep.property('y') + .that.equal(sub); }); - describe('using the `nested` flag', function () { // eslint-disable-line prefer-arrow-callback - it('should not affect the original assertion', function () { // eslint-disable-line prefer-arrow-callback + describe('using the `nested` flag', function() { + it('should not affect the original assertion', function() { expect({ x: 1, y: { x: 2, y: 3 } }).to.have.nested.property('y.x', 2); - expect({ x: 1, y: { x: 2, y: 3 } }) - .to.have.nested.deep.property('y.x', 2); + expect({ x: 1, y: { x: 2, y: 3 } }).to.have.nested.deep.property( + 'y.x', + 2 + ); }); - it('should not affect the original assertion using `not`', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertion using `not`', function() { expect({ x: 1, y: { x: 2 } }).not.to.have.nested.property('z.z'); expect({ x: 1, y: { x: 2 } }).not.to.have.nested.deep.property('z.z'); expect({ x: 1, y: { x: 2 } }).not.to.have.nested.property('z.z', 42); - expect({ x: 1, y: { x: 2 } }) - .not.to.have.nested.deep.property('z.z', 42); + expect({ x: 1, y: { x: 2 } }).not.to.have.nested.deep.property( + 'z.z', + 42 + ); }); - it('should fail given an inexisting property', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given an inexisting property', function() { fail(() => expect(nestedObj).to.have.nested.property(['y', 'z'])); - fail(() => expect(nestedObj) - .to.have.nested.deep.property(['y', 'z'])); + fail(() => + expect(nestedObj).to.have.nested.deep.property(['y', 'z']) + ); }); - it('should pass using `not` given an inexisting property', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given an inexisting property', function() { expect(nestedObj).not.to.have.nested.property(['y', 'z']); expect(nestedObj).not.to.have.nested.deep.property(['y', 'z']); expect(nestedObj).not.to.have.property('a', new Map({ x: 2 })); }); - it('should pass using `not` given an inexisting property and value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given an inexisting property and value', function() { expect(obj).not.to.have.nested.property(['y', 'x'], 'different'); expect(obj).not.to.have.nested.deep.property(['y', 'x'], 'different'); }); - it('should pass given an existing property', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given an existing property', function() { expect(nestedObj).to.have.nested.property(['y', 'x']); expect(nestedObj).to.have.nested.deep.property(['y', 'x']); }); - it('should pass given an index', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given an index', function() { const obj2 = Immutable.fromJS({ items: ['a', 'b', 'c'] }); expect(obj2).to.have.nested.property(['items', 2], 'c'); expect(obj2).to.have.nested.deep.property(['items', 2], 'c'); }); - it('should fail using `not` given an existing property', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given an existing property', function() { fail(() => expect(nestedObj).not.to.have.nested.property(['y', 'x'])); - fail(() => expect(nestedObj) - .not.to.have.nested.deep.property(['y', 'x'])); + fail(() => + expect(nestedObj).not.to.have.nested.deep.property(['y', 'x']) + ); }); - it('should fail given a property with a bad value', function () { // eslint-disable-line prefer-arrow-callback - fail(() => expect(nestedObj) - .to.have.nested.property(['y', 'x'], 'different')); - fail(() => expect(nestedObj) - .to.have.nested.deep.property(['y', 'x'], 'different')); + it('should fail given a property with a bad value', function() { + fail(() => + expect(nestedObj).to.have.nested.property(['y', 'x'], 'different') + ); + fail(() => + expect(nestedObj).to.have.nested.deep.property( + ['y', 'x'], + 'different' + ) + ); }); - it('should pass given a property with the good value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given a property with the good value', function() { expect(nestedObj).to.have.nested.property(['y', 'x'], 2); expect(nestedObj).to.have.nested.deep.property(['y', 'x'], 2); }); - it('should fail using `not` given a property with good value', function () { // eslint-disable-line prefer-arrow-callback - fail(() => expect(nestedObj) - .not.to.have.nested.property(['y', 'x'], 2)); - fail(() => expect(nestedObj) - .not.to.have.nested.deep.property(['y', 'x'], 2)); + it('should fail using `not` given a property with good value', function() { + fail(() => + expect(nestedObj).not.to.have.nested.property(['y', 'x'], 2) + ); + fail(() => + expect(nestedObj).not.to.have.nested.deep.property(['y', 'x'], 2) + ); }); - it('should pass using `not` given a property with a bad value', function () { // eslint-disable-line prefer-arrow-callback - expect(nestedObj) - .not.to.have.nested.property(['y', 'x'], 'different'); - expect(nestedObj) - .not.to.have.nested.deep.property(['y', 'x'], 'different'); + it('should pass using `not` given a property with a bad value', function() { + expect(nestedObj).not.to.have.nested.property( + ['y', 'x'], + 'different' + ); + expect(nestedObj).not.to.have.nested.deep.property( + ['y', 'x'], + 'different' + ); }); - it('should pass given an immutable value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given an immutable value', function() { const nestedObj2 = Immutable.fromJS({ foo: [{ bar: 42 }] }); - expect(nestedObj2) - .to.have.nested.property('foo[0]', new Map({ bar: 42 })); - expect(nestedObj2) - .to.have.nested.deep.property('foo[0]', new Map({ bar: 42 })); + expect(nestedObj2).to.have.nested.property( + 'foo[0]', + new Map({ bar: 42 }) + ); + expect(nestedObj2).to.have.nested.deep.property( + 'foo[0]', + new Map({ bar: 42 }) + ); }); }); - describe('given a string-based path', function () { // eslint-disable-line prefer-arrow-callback + describe('given a string-based path', function() { const nestedObj2 = Immutable.fromJS({ - items: [ - { name: 'Jane' }, - { name: 'John' }, - { name: 'Jim' }, - ], + items: [{ name: 'Jane' }, { name: 'John' }, { name: 'Jim' }], }); - it('should pass using `nested` given a single index', function () { // eslint-disable-line prefer-arrow-callback - expect(nestedObj2.get('items')).to.have.nested.property('[1]') + it('should pass using `nested` given a single index', function() { + expect(nestedObj2.get('items')) + .to.have.nested.property('[1]') .that.equals(new Map({ name: 'John' })); - expect(nestedObj2.get('items')).to.have.nested.deep.property('[1]') + expect(nestedObj2.get('items')) + .to.have.nested.deep.property('[1]') .that.equals(new Map({ name: 'John' })); }); - it('should pass using `nested` given a single key', function () { // eslint-disable-line prefer-arrow-callback - expect(nestedObj2).to.have.nested.property('items') - .that.equals(new List([ - new Map({ name: 'Jane' }), - new Map({ name: 'John' }), - new Map({ name: 'Jim' }), - ])); - expect(nestedObj2).to.have.nested.deep.property('items') - .that.equals(new List([ - new Map({ name: 'Jane' }), - new Map({ name: 'John' }), - new Map({ name: 'Jim' }), - ])); + it('should pass using `nested` given a single key', function() { + expect(nestedObj2) + .to.have.nested.property('items') + .that.equals( + new List([ + new Map({ name: 'Jane' }), + new Map({ name: 'John' }), + new Map({ name: 'Jim' }), + ]) + ); + expect(nestedObj2) + .to.have.nested.deep.property('items') + .that.equals( + new List([ + new Map({ name: 'Jane' }), + new Map({ name: 'John' }), + new Map({ name: 'Jim' }), + ]) + ); }); - it('should pass using `nested` starting with an index', function () { // eslint-disable-line prefer-arrow-callback - expect(nestedObj2.get('items')) - .to.have.nested.property('[0].name', 'Jane'); - expect(nestedObj2.get('items')) - .to.have.nested.deep.property('[0].name', 'Jane'); + it('should pass using `nested` starting with an index', function() { + expect(nestedObj2.get('items')).to.have.nested.property( + '[0].name', + 'Jane' + ); + expect(nestedObj2.get('items')).to.have.nested.deep.property( + '[0].name', + 'Jane' + ); }); - it('should pass using `nested` ending with an index', function () { // eslint-disable-line prefer-arrow-callback - expect(nestedObj2).to.have.nested.property('items[1]') + it('should pass using `nested` ending with an index', function() { + expect(nestedObj2) + .to.have.nested.property('items[1]') .that.equals(new Map({ name: 'John' })); - expect(nestedObj2).to.have.nested.deep.property('items[1]') + expect(nestedObj2) + .to.have.nested.deep.property('items[1]') .that.equals(new Map({ name: 'John' })); }); - it('should pass using `nested` given mix of keys and indices', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `nested` given mix of keys and indices', function() { expect(nestedObj2).to.have.nested.property('items[2].name', 'Jim'); - expect(nestedObj2) - .to.have.nested.deep.property('items[2].name', 'Jim'); + expect(nestedObj2).to.have.nested.deep.property( + 'items[2].name', + 'Jim' + ); }); - it('should expect unescaped path strings', function () { // eslint-disable-line prefer-arrow-callback + it('should expect unescaped path strings', function() { const css = new Map({ '.link[target]': 42 }); expect(css).to.have.property('.link[target]', 42); expect(css).to.have.deep.property('.link[target]', 42); }); - it('should expect escaped path strings using `nested`', function () { // eslint-disable-line prefer-arrow-callback + it('should expect escaped path strings using `nested`', function() { const nestedCss = new Map({ '.link': new Map({ '[target]': 42 }) }); expect(nestedCss).to.have.nested.property('\\.link.\\[target\\]', 42); - expect(nestedCss) - .to.have.nested.deep.property('\\.link.\\[target\\]', 42); + expect(nestedCss).to.have.nested.deep.property( + '\\.link.\\[target\\]', + 42 + ); }); }); }); - describe('size method', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given the right size', function () { // eslint-disable-line prefer-arrow-callback + describe('size method', function() { + it('should pass given the right size', function() { expect(list3).to.have.size(3); }); - it('should pass using `not` given the wrong size', function () { // eslint-disable-line prefer-arrow-callback + it('should pass using `not` given the wrong size', function() { expect(list3).to.not.have.size(42); }); - it('should also work with alias sizeOf', function () { // eslint-disable-line prefer-arrow-callback + it('should also work with alias sizeOf', function() { expect(list3).to.have.sizeOf(3); expect(list3).to.not.have.sizeOf(42); }); - it('should fail given the wrong size', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given the wrong size', function() { fail(() => expect(list3).to.have.size(42)); }); - it('should fail using `not` given the right size', function () { // eslint-disable-line prefer-arrow-callback + it('should fail using `not` given the right size', function() { fail(() => expect(list3).to.not.have.size(3)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { expect(clonedImmutableList).to.have.size(3); }); }); - describe('size property', function () { // eslint-disable-line prefer-arrow-callback - it('above should pass given a good min size', function () { // eslint-disable-line prefer-arrow-callback + describe('size property', function() { + it('above should pass given a good min size', function() { expect(list3).to.have.size.above(2); }); - it('above should pass using `not` given a bad min size', function () { // eslint-disable-line prefer-arrow-callback + it('above should pass using `not` given a bad min size', function() { expect(list3).to.not.have.size.above(42); }); - it('aliases of above should also work', function () { // eslint-disable-line prefer-arrow-callback + it('aliases of above should also work', function() { expect(list3).to.have.size.gt(2); expect(list3).to.have.size.greaterThan(2); expect(list3).to.not.have.size.gt(42); expect(list3).to.not.have.size.greaterThan(42); }); - it('should not affect the original assertions of above', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions of above', function() { expect('foo').to.have.length.above(2); expect([1, 2, 3]).to.have.length.above(2); }); - it('above should fail given a bad min size', function () { // eslint-disable-line prefer-arrow-callback + it('above should fail given a bad min size', function() { fail(() => expect(list3).to.have.size.above(42)); }); - it('above should fail using `not` given a good min size', function () { // eslint-disable-line prefer-arrow-callback + it('above should fail using `not` given a good min size', function() { fail(() => expect(list3).to.not.have.size.above(2)); }); - it('below should pass given a good max size', function () { // eslint-disable-line prefer-arrow-callback + it('below should pass given a good max size', function() { expect(list3).to.have.size.below(42); }); - it('below should pass using `not` given a bad max size', function () { // eslint-disable-line prefer-arrow-callback + it('below should pass using `not` given a bad max size', function() { expect(list3).to.not.have.size.below(1); }); - it('aliases of below should also work', function () { // eslint-disable-line prefer-arrow-callback + it('aliases of below should also work', function() { expect(list3).to.have.size.lt(4); expect(list3).to.have.size.lessThan(4); expect(list3).to.not.have.size.lt(1); expect(list3).to.not.have.size.lessThan(1); }); - it('should not affect the original assertions of below', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions of below', function() { expect('foo').to.have.length.below(4); expect([1, 2, 3]).to.have.length.below(4); }); - it('below should fail given a bad max size', function () { // eslint-disable-line prefer-arrow-callback + it('below should fail given a bad max size', function() { fail(() => expect(list3).to.have.size.below(1)); }); - it('below should fail using `not` given a good max size', function () { // eslint-disable-line prefer-arrow-callback + it('below should fail using `not` given a good max size', function() { fail(() => expect(list3).to.not.have.size.below(42)); }); - it('within should pass given a good range', function () { // eslint-disable-line prefer-arrow-callback + it('within should pass given a good range', function() { expect(list3).to.have.size.within(2, 42); }); - it('within should pass using `not` given a bad range', function () { // eslint-disable-line prefer-arrow-callback + it('within should pass using `not` given a bad range', function() { expect(list3).to.not.have.size.within(10, 20); }); - it('should not affect the original assertions of within', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions of within', function() { expect('foo').to.have.length.within(2, 4); expect([1, 2, 3]).to.have.length.within(2, 4); }); - it('within should fail given a bad range', function () { // eslint-disable-line prefer-arrow-callback + it('within should fail given a bad range', function() { fail(() => expect(list3).to.have.size.within(10, 20)); }); - it('within should fail using `not` given a good range', function () { // eslint-disable-line prefer-arrow-callback + it('within should fail using `not` given a good range', function() { fail(() => expect(list3).to.not.have.size.within(2, 42)); }); - it('least should pass given a good min size', function () { // eslint-disable-line prefer-arrow-callback + it('least should pass given a good min size', function() { expect(list3).to.have.size.of.at.least(2); }); - it('least should pass using `not` given a bad min size', function () { // eslint-disable-line prefer-arrow-callback + it('least should pass using `not` given a bad min size', function() { expect(list3).to.not.have.size.of.at.least(42); }); - it('aliases of least should also work', function () { // eslint-disable-line prefer-arrow-callback + it('aliases of least should also work', function() { expect(list3).to.have.size.gte(2); expect(list3).to.not.have.size.gte(42); }); - it('should not affect the original assertions of least', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions of least', function() { expect('foo').to.have.length.of.at.least(2); expect([1, 2, 3]).to.have.length.of.at.least(3); }); - it('least should fail given a bad min size', function () { // eslint-disable-line prefer-arrow-callback + it('least should fail given a bad min size', function() { fail(() => expect(list3).to.have.size.of.at.least(42)); }); - it('least should fail using `not` given a good min size', function () { // eslint-disable-line prefer-arrow-callback + it('least should fail using `not` given a good min size', function() { fail(() => expect(list3).to.not.have.size.of.at.least(2)); }); - it('most should pass given a good max size', function () { // eslint-disable-line prefer-arrow-callback + it('most should pass given a good max size', function() { expect(list3).to.have.size.of.at.most(42); }); - it('most should pass using `not` given a bad max size', function () { // eslint-disable-line prefer-arrow-callback + it('most should pass using `not` given a bad max size', function() { expect(list3).to.not.have.size.of.at.most(2); }); - it('aliases of most should also work', function () { // eslint-disable-line prefer-arrow-callback + it('aliases of most should also work', function() { expect(list3).to.have.size.lte(42); expect(list3).to.not.have.size.lte(2); }); - it('should not affect the original assertions of most', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertions of most', function() { expect('foo').to.have.length.of.at.most(4); expect([1, 2, 3]).to.have.length.of.at.most(3); }); - it('most should fail given a good max size', function () { // eslint-disable-line prefer-arrow-callback + it('most should fail given a good max size', function() { fail(() => expect(list3).to.have.size.of.at.most(2)); }); - it('most should fail using `not` given a bad max size', function () { // eslint-disable-line prefer-arrow-callback + it('most should fail using `not` given a bad max size', function() { fail(() => expect(list3).to.not.have.size.of.at.most(42)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { expect(clonedImmutableList).to.have.size.above(2); }); }); }); - describe('TDD interface', function () { // eslint-disable-line prefer-arrow-callback - describe('equal assertion', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given equal values', function () { // eslint-disable-line prefer-arrow-callback + describe('TDD interface', function() { + describe('equal assertion', function() { + it('should pass given equal values', function() { assert.equal(list3, List.of(1, 2, 3)); }); - it('should pass given deeply equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given deeply equal values', function() { assert.equal(deepMap, sameDeepMap); }); - it('should not affect the original assertion', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertion', function() { assert.equal(42, 42); assert.equal(3, '3'); }); // See https://github.com/astorije/chai-immutable/issues/7 - it('should display a helpful failure output on big objects', function () { // eslint-disable-line prefer-arrow-callback + it('should display a helpful failure output on big objects', function() { const actual = new Map({ foo: 'foo foo foo foo foo foo foo foo ' }); const expected = new Map({ bar: 'bar bar bar bar bar bar bar bar ' }); // AssertionError: expected { Object (foo) } to equal { Object (bar) } @@ -872,115 +913,115 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal ); }); - it('should fail given a non-Immutable value', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given a non-Immutable value', function() { fail(() => assert.equal([], new List())); }); - it('should fail given different values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given different values', function() { fail(() => assert.equal(list3, new List())); }); - it('should fail given deeply different values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given deeply different values', function() { fail(() => assert.equal(deepMap, differentDeepMap)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { assert.equal(clonedImmutableList, List.of(1, 2, 3)); }); }); - describe('notEqual assertion', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given different values', function () { // eslint-disable-line prefer-arrow-callback + describe('notEqual assertion', function() { + it('should pass given different values', function() { assert.notEqual(list3, new List()); }); - it('should pass given deeply different values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given deeply different values', function() { assert.notEqual(deepMap, differentDeepMap); }); - it('should not affect the original assertion', function () { // eslint-disable-line prefer-arrow-callback + it('should not affect the original assertion', function() { assert.notEqual('oui', 'non'); assert.notEqual({ foo: 'bar' }, { foo: 'bar' }); }); - it('should pass given a non-Immutable value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given a non-Immutable value', function() { assert.notEqual([], new List()); }); - it('should fail given equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given equal values', function() { fail(() => assert.notEqual(list3, List.of(1, 2, 3))); }); - it('should fail given deeply equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given deeply equal values', function() { fail(() => assert.notEqual(deepMap, sameDeepMap)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { assert.notEqual(clonedImmutableList, List.of()); }); }); - describe('unoverridden strictEqual and deepEqual assertions', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given equal values', function () { // eslint-disable-line prefer-arrow-callback + describe('unoverridden strictEqual and deepEqual assertions', function() { + it('should pass given equal values', function() { assert.strictEqual(list3, List.of(1, 2, 3)); assert.deepEqual(list3, List.of(1, 2, 3)); }); - it('should pass given deeply equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given deeply equal values', function() { assert.strictEqual(deepMap, sameDeepMap); assert.deepEqual(deepMap, sameDeepMap); }); - it('should fail given different values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given different values', function() { fail(() => assert.strictEqual(list3, new List())); fail(() => assert.deepEqual(list3, new List())); }); - it('should fail given deeply different values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given deeply different values', function() { fail(() => assert.strictEqual(deepMap, differentDeepMap)); fail(() => assert.deepEqual(deepMap, differentDeepMap)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { assert.strictEqual(clonedImmutableList, List.of(1, 2, 3)); assert.deepEqual(clonedImmutableList, List.of(1, 2, 3)); }); }); - describe('unoverridden notStrictEqual and notDeepEqual assertions', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given different values', function () { // eslint-disable-line prefer-arrow-callback + describe('unoverridden notStrictEqual and notDeepEqual assertions', function() { + it('should pass given different values', function() { assert.notStrictEqual(list3, new List()); assert.notDeepEqual(list3, new List()); }); - it('should pass given deeply different values', function () { // eslint-disable-line prefer-arrow-callback + it('should pass given deeply different values', function() { assert.notStrictEqual(deepMap, differentDeepMap); assert.notDeepEqual(deepMap, differentDeepMap); }); - it('should fail given equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given equal values', function() { fail(() => assert.notStrictEqual(list3, List.of(1, 2, 3))); fail(() => assert.notDeepEqual(list3, List.of(1, 2, 3))); }); - it('should fail given deeply equal values', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given deeply equal values', function() { fail(() => assert.notStrictEqual(deepMap, sameDeepMap)); fail(() => assert.notDeepEqual(deepMap, sameDeepMap)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { assert.notStrictEqual(clonedImmutableList, new List()); assert.notDeepEqual(clonedImmutableList, new List()); }); }); - describe('include assertion', function () { // eslint-disable-line prefer-arrow-callback + describe('include assertion', function() { const map1 = new Map({ a: 1 }); const map2 = new Map({ b: 2 }); const list = new List([map1, map2]); const map = new Map({ foo: map1, bar: map2 }); - it('should ensure deep equality', function () { // eslint-disable-line prefer-arrow-callback + it('should ensure deep equality', function() { assert.include(list, map1); assert.include(list, new Map({ a: 1 })); @@ -988,24 +1029,24 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal assert.include(map, new Map({ a: 1 })); }); - it('should not treat partial collections as sub-collections', function () { // eslint-disable-line prefer-arrow-callback + it('should not treat partial collections as sub-collections', function() { fail(() => assert.include(map, new Map({ foo: map1 }))); fail(() => assert.include(map, new Map({ foo: map1, bar: map2 }))); }); }); - describe('notInclude assertion', function () { // eslint-disable-line prefer-arrow-callback + describe('notInclude assertion', function() { const map1 = new Map({ a: 1 }); const map2 = new Map({ b: 2 }); const list = new List([map1, map2]); const map = new Map({ foo: map1, bar: map2 }); - it('should ensure deep equality', function () { // eslint-disable-line prefer-arrow-callback + it('should ensure deep equality', function() { assert.notInclude(map, new Map({ foo: map1 })); assert.notInclude(map, new Map({ foo: map1, bar: map2 })); }); - it('should not treat partial collections as sub-collections', function () { // eslint-disable-line prefer-arrow-callback + it('should not treat partial collections as sub-collections', function() { fail(() => assert.notInclude(list, map1)); fail(() => assert.notInclude(list, new Map({ a: 1 }))); @@ -1014,39 +1055,39 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal }); }); - describe('property assertions', function () { // eslint-disable-line prefer-arrow-callback + describe('property assertions', function() { const obj = Immutable.fromJS({ x: 1 }); const nestedObj = Immutable.fromJS({ x: 1, y: { x: 2, y: 3 } }); - it('should pass for existing property', function () { // eslint-disable-line prefer-arrow-callback + it('should pass for existing property', function() { assert.property(obj, 'x'); }); - it('should fail for missing property', function () { // eslint-disable-line prefer-arrow-callback + it('should fail for missing property', function() { fail(() => assert.property(obj, 'z')); }); - it('should pass for missing property using `not`', function () { // eslint-disable-line prefer-arrow-callback + it('should pass for missing property using `not`', function() { assert.notProperty(obj, 'z'); }); - it('should fail for existing property using `not`', function () { // eslint-disable-line prefer-arrow-callback + it('should fail for existing property using `not`', function() { fail(() => assert.notProperty(obj, 'x')); }); - it('should pass for existing property and value', function () { // eslint-disable-line prefer-arrow-callback + it('should pass for existing property and value', function() { assert.propertyVal(obj, 'x', 1); assert.deepPropertyVal(obj, 'x', 1); }); - it('should fail for wrong property or value', function () { // eslint-disable-line prefer-arrow-callback + it('should fail for wrong property or value', function() { fail(() => assert.propertyVal(obj, 'z', 1)); fail(() => assert.deepPropertyVal(obj, 'z', 1)); fail(() => assert.propertyVal(obj, 'x', 42)); fail(() => assert.deepPropertyVal(obj, 'x', 42)); }); - it('should pass for wrong property or value using `not`', function () { // eslint-disable-line prefer-arrow-callback + it('should pass for wrong property or value using `not`', function() { assert.notPropertyVal(obj, 'z', 1); assert.notDeepPropertyVal(obj, 'z', 1); assert.notPropertyVal(obj, 'x', 42); @@ -1055,35 +1096,35 @@ describe('chai-immutable', function () { // eslint-disable-line prefer-arrow-cal assert.notDeepPropertyVal(obj, 'foo', new Map({ bar: 'baz' })); }); - it('should fail for existing property and value using `not`', function () { // eslint-disable-line prefer-arrow-callback + it('should fail for existing property and value using `not`', function() { fail(() => assert.notPropertyVal(obj, 'x', 1)); fail(() => assert.notDeepPropertyVal(obj, 'x', 1)); }); - it('should succeed for equal nested property', function () { // eslint-disable-line prefer-arrow-callback + it('should succeed for equal nested property', function() { assert.nestedProperty(nestedObj, ['y', 'x']); }); - it('should fail for unequal nested property', function () { // eslint-disable-line prefer-arrow-callback + it('should fail for unequal nested property', function() { fail(() => assert.nestedPropertyVal(nestedObj, ['y', 'x'], 42)); fail(() => assert.deepNestedPropertyVal(nestedObj, ['y', 'x'], 42)); }); }); - describe('sizeOf assertion', function () { // eslint-disable-line prefer-arrow-callback - it('should pass given the right size', function () { // eslint-disable-line prefer-arrow-callback + describe('sizeOf assertion', function() { + it('should pass given the right size', function() { assert.sizeOf(list3, 3); }); - it('should work with empty collections', function () { // eslint-disable-line prefer-arrow-callback + it('should work with empty collections', function() { assert.sizeOf(new List(), 0); }); - it('should fail given the wrong size', function () { // eslint-disable-line prefer-arrow-callback + it('should fail given the wrong size', function() { fail(() => assert.sizeOf(list3, 42)); }); - it('should work if using different copies of Immutable', function () { // eslint-disable-line prefer-arrow-callback + it('should work if using different copies of Immutable', function() { assert.sizeOf(clonedImmutableList, 3); }); });