Commit graph

382 commits

Author SHA1 Message Date
Aleksey Shvayka
c5ca76c551 Refactor utils.addChainableMethod helper (#900)
* replace __proto__ with Object.setPrototypeOf

* remove hardcoded keys

* cache non-configurable keys
2017-01-12 19:14:29 -02:00
Grant Snodgrass
bf71196c7f test(includeStack): add should interface
Only the `expect` interface was being tested for correct stack traces.
This commit adds identical tests for the `should` interface.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
b88e53639e fix: remove proxy frames from stack traces
Proxy-related implementation frames were showing up in the stack
traces for failed property assertions. This commit removes them by
setting the proxy getter (instead of the property getter) as the
starting point to remove all implementation frames.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
8fa4f78574 test(includeStack): improve tests
Only a couple of types of assertions were being tested for correct
stack traces. This commit cleans up the existing tests and adds tests
for the missing assertion types.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
5a1e6764d6 refactor(proxify): move feature detection to util
Currently, only one module needs to detect if Chai's proxy protection
is enabled. However, upcoming changes will involve performing this
detection in other modules as well. This commit moves the detection
logic to its own utility module for easy reuse.
2017-01-03 16:21:16 -05:00
Grant Snodgrass
ce9a2c283b feat(utils): add length guard to methods
When the `length` assertion is chained directly off of an uninvoked
method, it references `function`'s built-in `length` property instead
of Chai's `length` assertion. This commit adds a guard to Chai methods
to detect this problem and throw a helpful error message that advises
the user on how to correct it.
2017-01-02 21:00:51 -05:00
Grant Snodgrass
ae69f27532 refactor(lengthOf): favor it over length
- The method part of the `length` assertion was slated for deprecation
  due to a compatibility issue in legacy environments. The decision to
  deprecate `length` was reversed per #684. This commit replaces the
  deprecation notice with a recommendation to favor `lengthOf` over
  `length` due to the compatibility issue.

- The `lengthOf` assertion wasn't a true alias of `length` because it
  was a method assertion instead of a chainable method assertion. This
  commit changes `lengthOf` into a chainable method assertion that's
  identical to `length`, and updates tests and docs accordingly.

- Updates docs to classify `length` as an alias of `lengthOf`.

- Updates docs of related assertions to use `lengthOf` instead of
  `length`.
2017-01-02 12:04:12 -05:00
Grant Snodgrass
8a2ef676e3 test: comment out broken tests in Safari 10 (#869)
Three tests on the `should` interface are failing in Safari 10 due to a
bug related to proxies. These tests should be re-enabled once the bug is
fixed. See https://github.com/chaijs/chai/issues/855.
2016-11-17 09:36:48 -02:00
lucasfcosta
93be4b15d9 Use external get-func-name module 2016-10-16 11:10:36 -02:00
Grant Snodgrass
abbc771aff Update type-detect to v3.0.0 and fix issues
- Use typeof instead of type-detect whenever possible for performance
- Fix casing whenever type-detect is used per v3.0.0 breaking change
- Remove duplicate type-detect calls by storing results in variables
2016-10-09 09:59:32 -04:00
lucasfcosta
a33ab48186 Use external pathval module instead of internal util modules 2016-10-08 19:16:11 -03:00
Aleksey Shvayka
2ef786d254 Add .empty to assert interface (#828)
* improve jsdoc

* add .empty to assert interface

* add assert.empty tests

* add Map and Set to jsdoc
2016-10-05 12:28:22 -03:00
Aleksey Shvayka
ac0c5f1a16 Do not suppress TypeErrors thrown on integrity checks (#823)
* document behavior for primitives

* simplify integrity checks

* add regression tests

* better tests

* update comment

* add comments to tests
2016-10-04 15:20:42 -03:00
Aleksey Shvayka
fdd0f8cffe Make utils.getName more robust & use it in empty (#813)
* use utils.getName

* remove extra .to in tests

* make getName even more robust

* add basic tests
2016-10-02 15:57:40 -04:00
Aleksey Shvayka
c38bfec30c Make empty assertion work with es6 collections (#814)
* support Map and Set

* throw on weak collections

* called on => passed

* account for partial implementations
2016-10-02 15:33:59 -03:00
Aleksey Shvayka
5b170b2e3b Make 'empty' throw on non-string primitives and functions (#812)
* Make 'empty' throw on non-string primitives and functions

* Update jsdoc

* improve error messages

* fix symbol to string coercion for Node 0.12

* use utils.inspect
2016-10-01 15:58:45 -03:00
Grant Snodgrass
5dd96a0a3d Merge pull request #810 from meeber/refactor-own-property
Refactor `ownProperty`
2016-09-29 16:12:38 -04:00
Grant Snodgrass
edfe064774 Refactor ownProperty
- Add `own` flag
- Make `ownProperty` and `haveOwnProperty` aliases of `own.property`
- Add `deep` support to `own.property`
- Add `assert.deepOwnPropertyVal`
- Add `assert.notDeepOwnPropertyVal`
2016-09-28 17:24:00 -04:00
Grant Snodgrass
1f36393d1c Standardize failed property assertion messages 2016-09-28 06:51:26 -04:00
lucasfcosta
9498811fe2 Deep flag support for keys assertion 2016-09-27 18:00:14 -03:00
Grant Snodgrass
eac90a5209 Wrap non-chainable methods in proxies 2016-09-25 20:13:19 -04:00
lucasfcosta
fdc1dbc42b Fix bug when trying to call inspect on an Assertion 2016-09-22 19:38:19 -03:00
Lucas Vieira
d0242ee9e5 Not check instaceOf if __proto__ is not supported 2016-09-19 15:26:35 -03:00
Lucas Fernandes da Costa
7683356fff Merge pull request #799 from vieiralucas/consistency-return-new-assertion
Return new assertion with flags copied over instead of this. Fix #791
2016-09-19 11:25:43 -03:00
Lucas Vieira
5d11228cfa Wrap some utilities tests with describe so we can cleanup in an after block even if they fail 2016-09-18 23:04:06 -03:00
Lucas Vieira
1ae0a41be2 Return new assertion instead of this for overwriteChainableMethod 2016-09-15 02:34:27 -03:00
Lucas Vieira
f6c4fa3939 Remove new methods and properties after using them for test 2016-09-15 02:34:27 -03:00
Lucas Vieira
27f426557d Return new assertion instead of this for addChainableMethod 2016-09-15 01:00:01 -03:00
Lucas Vieira
4501970540 Return new assertion instead of this for overwriteMethod 2016-09-15 01:00:01 -03:00
Lucas Vieira
031085d1d9 Add toJSON to proxyExcludedKeys 2016-09-15 00:03:16 -03:00
Lucas Vieira
4101fdfbfd Return new assertion instead of this for overwriteProperty 2016-09-14 13:39:31 -03:00
Lucas Fernandes da Costa
662b76c82d Merge pull request #796 from vieiralucas/verify-type-round2
Verify types on increase | decrease
2016-09-12 15:01:45 -03:00
Lucas Vieira
c802d38dbe Add tests that ensure assert.atMost and assert.atLeast are checking type 2016-09-10 17:01:26 -03:00
Lucas Vieira
43b22c8fac Verify types on increase | decrease 2016-09-10 17:00:13 -03:00
Grant Snodgrass
e24b66ee49 Fix broken tests when using Node v6.5 2016-09-10 15:06:03 -04:00
Grant Snodgrass
4a009decbf Fix broken test after rebasing 4.x.x branch 2016-09-08 09:37:23 -04:00
Lucas Vieira
c3e828534b Verify types on within and related assertions 2016-09-08 09:37:23 -04:00
lucasfcosta
df1a89241b ownProperty assertions on Assert interface 2016-09-08 09:37:22 -04:00
lucasfcosta
16101af347 Assertion subject (obj) changes when using ownProperty assertion 2016-09-08 09:37:22 -04:00
lucasfcosta
01189490bd Truncate typedArrays according to their string representation 2016-09-08 09:37:22 -04:00
lucasfcosta
4d314b614b Fix truncateThreshold 2016-09-08 09:37:22 -04:00
lucasfcosta
aae52f2f42 Minor inspect code style fixes 2016-09-08 09:37:22 -04:00
lucasfcosta
b90ba4e5a0 Truncate long typedArray 2016-09-08 09:37:22 -04:00
lucasfcosta
8123bf778c formatTypedArray function 2016-09-08 09:37:22 -04:00
lucasfcosta
0a8869643c New showDiff behaviour also depending on expected and actual values 2016-09-08 09:37:22 -04:00
Whitney Young
04aa795b73 No longer silently allowing undefined method calls. Fixes #467. 2016-09-08 09:37:22 -04:00
Sakthipriyan Vairamani
d2884a6baa handle NaN properly in assertions
Fixes: #498
2016-09-08 09:37:22 -04:00
Dai
128c1126ac Updated code based on discussion 2016-09-08 09:37:22 -04:00
Dai
e0ee3def23 Added handling for undefined and null (fails on negate flag too) 2016-09-08 09:37:22 -04:00
not-an-aardvark
e8085b0ad8
Add fix suggestions when accessing a nonexistent property in proxy mode
fixes #771
2016-09-07 21:34:29 -04:00