Commit graph

701 commits

Author SHA1 Message Date
Aleksey Shvayka
6586e2dcbe add missing vars 2017-09-06 22:18:25 +03:00
Alhadis
b534fca6c0 chai@4.1.2 2017-08-31 21:57:15 +10:00
Alhadis
31c35595d7 Use a hardcoded no-op instead of instancing
The use of `new Function()` causes an EvalError if the environment's CSP
forbids execution of unsafe-eval. As there's no runtime evaluation being
performed, it's better to use a plain anonymous function instead.
2017-08-24 05:35:11 +10:00
Grant Snodgrass
ac48db3a72 chai@4.1.1 2017-08-04 18:29:14 -04:00
Keith Cirkel
92d2cca468 docs: re-indent hasAnyKeys code
Refs #1014
2017-08-02 21:11:36 +01:00
Keith Cirkel
b625497f1e Merge pull request #1012 from meeber/fix-include-types
fix: `.include` to work with all objects
2017-08-02 20:59:47 +01:00
zenheart
113a5b8b6a fix: correct hasAnyKeys comment error 2017-08-02 08:55:45 +08:00
Grant Snodgrass
c01cf30de9 fix: .include to work with all objects
Overly strict type-checking was causing `.include` to reject `Error`
objects and objects with a custom `@@toStringTag`.
2017-07-31 17:22:58 -04:00
Grant Snodgrass
c107abb319 fix: .instanceof to allow DOM interfaces in IE11 2017-07-24 18:57:42 -04:00
v1adko
45cb32710a chai@4.1.0 2017-06-24 09:30:03 +03:00
Aleksey Shvayka
2eddd79002 Add ES6 collection support to include() (#994)
* fix error messages tests

* add tests

* add implementation

* performance tweaks

* add tests for SameValueZero

* drop weakmap support

* update docs
2017-06-23 15:35:07 -07:00
Vlad Kolbaya
3c932e21e6 feat: allow dates for isBelow and isAbove assertions (#990)
* Fixed most tests

* Fix date uniformity (UTC)

* Add comment

* Cleanup

* Change extra functions (WIP)

* Finished tests

* Add master chai.js back

* Uncomment failing tests

* Update master and tests

* Actual seconds, duh

* Refactor 'above'

* Update all methods

* More explicit error

* Documentation - articles consistency

* Custom message test in assert

* No parenthesis in should

* Custom message for isAbove
2017-06-23 12:54:23 +01:00
Keith Cirkel
5daceabe7d Merge pull request #988 from samlanning/missing-var
Add a missing var keyword found by lgtm.com
2017-06-19 10:50:41 +01:00
Keith Cirkel
9116bc8591 Merge pull request #993 from meeber/refactor-expect-types
refactor: `expectTypes` to access `ssfi` flag
2017-06-19 10:48:23 +01:00
Grant Snodgrass
e7b23846b4 refactor: expectTypes to access ssfi flag
The `ssfi` flag doesn't need to be passed to the `expectTypes`
util function because it can access it directly from the assertion
object.
2017-06-11 08:33:48 -04:00
Grant Snodgrass
e6ddf64c8f fix: check target's type in .property assertion
Previously, the `.property` assertion failed ungracefully if the target was `null` or `undefined`. This commit causes an `AssertionError` to be thrown instead so that the ssfi flag and custom error messages are respected.
2017-06-10 17:51:50 -04:00
Sam Lanning
7e466af33b Add a missing var keyword found by lgtm.com 2017-06-05 18:50:33 -07:00
Lucas Fernandes da Costa
616cf8bf88 Revert get version package json (#986)
* Revert getting version from package.json

* chai@4.0.2
2017-06-05 14:12:19 -03:00
Keith Cirkel
0825826059 Merge pull request #964 from zetamorph/assert-nestedInclude-ownInclude
assert: add nestedInclude, deepNestedInclude, ownInclude and deepOwnInclude
2017-05-09 10:08:36 +01:00
Grant Snodgrass
f3adfd911e fix: PhantomJS 1.x incompatibility (#966) 2017-05-08 17:22:54 -03:00
Johannes Loewe
b744130df9 Assert: made documentation more descriptive
Assert: made documentation more descriptive
2017-05-07 14:49:42 +02:00
Johannes Loewe
40bb490060 assert interface: add .deepOwnInclude and notdeepOwnInclude 2017-05-05 00:54:11 +02:00
Johannes Loewe
97b6243431 assert interface: add .ownInclude and .notOwnInclude 2017-05-05 00:54:11 +02:00
Johannes Loewe
24d7fa3849 assert interface: add deepNestedInclude and notDeepNestedInclude 2017-05-05 00:54:11 +02:00
Johannes Loewe
7063b940a8 assert interface: add nestedInclude and notNestedInclude 2017-05-05 00:54:10 +02:00
Grant Snodgrass
f80d699a50 docs: overhaul bdd documentation 2017-04-08 21:41:45 -04:00
Grant Snodgrass
dce6415d0a style: rename target argument to subject
Most assertions use the term "target" to refer to the object under
test, but a few assertions also had a `target` argument, resulting in
an overloaded term that was difficult to document. This commit
renames every `target` argument to `subject`.
2017-04-08 09:23:27 -04:00
Grant Snodgrass
7f8a268e52 fix: always honor custom message 2017-04-04 17:28:19 -04:00
Grant Snodgrass
8fad9c8000 refactor: rename keep_ssfi to lockSsfi 2017-03-23 18:20:41 -04:00
Grant Snodgrass
b584b94c24 fix: remove frames from assert interface stack
- Make it so that only `AssertionError` is thrown from inside of an
  assert interface wrapper function

- Always set `ssfi` to the current function when creating a new
  `AssertionError` inside of an assert interface wrapper function

- Always set `ssfi` to the current function when creating a new
  `Assertion` inside of an assert interface wrapper function,
  and set the `keep_ssfi` flag

- Improve the `globalErr` test helper function to also validate that the
  thrown error's stack trace doesn't contain frames from the assert
  interface
2017-03-23 18:20:41 -04:00
Grant Snodgrass
4b090100aa fix: remove frames from bdd interface stack
- Make it so that only `AssertionError` is thrown from inside of an
  assertion

- Always pass the current `ssfi` to a `new AssertionError` inside of an
  assertion

- Always pass the current `ssfi` to a new `Assertion` inside of an
  assertion, and set the `keep_ssfi` flag

- Improve the `globalErr` test helper function to also validate that
  the thrown error's stack trace doesn't contain implementation frames
2017-03-23 18:20:38 -04:00
Grant Snodgrass
cf84f95505 feat: improve keep_ssfi flag
- Allows the `keep_ssfi` flag to be set when creating new Assertion
  objects by providing its value as the fourth argument.

- Updates the `transferFlags` util to only transfer `keep_ssfi` when the
  `includeAll` argument is set to `true`.

- Updates assertion creation and proxify utils to only set `ssfi` if
  `keep_ssfi` isn't set.

- Updates inline docs to reflect expanded usage of `keep_ssfi`.
2017-03-23 18:04:15 -04:00
Keith Cirkel
ef2bf66d7c Merge pull request #899 from lucasfcosta/throw-for-non-functions-on-instanceof
Throw error when instanceof is passed something that is not a function as constructor
2017-03-23 09:55:55 +00:00
Keith Cirkel
011612c7b3 Merge pull request #924 from meeber/fix-not-have-keys
fix: make negated `.keys` consider size of sets
2017-03-23 09:54:24 +00:00
lucasfcosta
011815305a Throw error when instanceof is passed something that is not a function as constructor 2017-02-15 21:56:26 -02:00
Grant Snodgrass
a7e1200db4 fix: wrong assertion types (#925)
BREAKING CHANGE: `.change`, `.increase`, and `.decrease` changed from
Chainable Method Assertions to Method Assertions. They don't have any
chaining behavior, and there's no generic semantic benefit to chaining
them.
2017-02-13 22:23:54 -02:00
Grant Snodgrass
f37d2c223b fix: make negated .keys consider size of sets
When neither the `contains` nor `any` flags are set, the `.keys`
assertion implicitly means `.all.keys` and thus requires the target
and given sets to be the same size. Therefore, `not.keys` implicitly
means `.not.all.keys`, and should thus pass when the target and given
sets aren't the same size, even if the target set is a superset of the
given set. This commit enables this behavior.
2017-01-30 18:34:42 -05:00
Aaron Sofaly
38d3ccaf0c remove space between method name and opening parenthesis 2017-01-22 15:06:15 -07:00
Aaron Sofaly
251fa57c16 added a period before each method 2017-01-22 14:34:01 -07:00
Aaron Sofaly
0334f17868 updated headlines to use h3's instead of h1's 2017-01-22 14:26:57 -07:00
Aaron Sofaly
1a47ff1a5f added headline for inspect util 2017-01-22 14:22:30 -07:00
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
0c0983618e refactor(Assertion): small edit and improve docs
- Rename third parameter of Assertion constructor from `stack` to
  `ssfi` for consistency's sake.
- Add documentation to Assertion constructor explaining what the `object`,
  `message`, and `ssfi` flags are for.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
82ca613d0f refactor(ssfi): remove dead code and update docs
There was some dead code leftover from before `includeStack` was made
into a config value (as opposed to existing as a property on the
Assertion object). This commit removes that dead code, and adds inline
documentation for the remaining stack-related code.
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
96f958c814 refactor(utils): improve function names
Many of the utility functions had slightly misleading names or no
names at all. This commit renames the functions with misleading names
and adds names to functions that were missing one.
2017-01-03 16:23:09 -05:00
Grant Snodgrass
78f1808735 refactor(proxify): use Reflect for property access
The proper way to perform an operation's original behavior from
within a proxy trap is by using `Reflect`.
2017-01-03 16:21:16 -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