Commit graph

416 commits

Author SHA1 Message Date
Grant Snodgrass
a5a90cbd9f Add .deep.property for deep equality comparisons 2016-07-25 20:45:08 -04:00
Grant Snodgrass
92768fd0da Breaking: Rename .deep.property to .nested.property
- Previously, the `deep` flag had unexpected behavior when used with the
`property` assertion: Instead of switching from strict to deep equality,
it unlocked the ability to use dot and bracket notation when referencing
property names. This behavior now belongs to the new `nested` flag.
- assert.deepProperty renamed to assert.nestedProperty
- assert.notDeepProperty renamed to assert.notNestedProperty
- assert.deepPropertyVal renamed to assert.nestedPropertyVal
- assert.notDeepPropertyVal renamed to assert.notNestedPropertyVal
2016-07-25 18:59:01 -04:00
Grant Snodgrass
576489a3be Breaking: Change .not.property(name, val) behavior
- Previously, `expect(obj).not.property(name, val)` would throw an Error
if `obj` didn't have a property named `name`. This change causes the
assertion to pass instead.
- assert.propertyNotVal renamed to assert.notPropertyVal
- assert.deepPropertyNotVal renamed to assert.notDeepPropertyVal
2016-07-24 19:52:01 -04:00
Keith Cirkel
cc7799c416 Merge pull request #739 from meeber/duplicate-members
Fix duplicate handling in members assertion
2016-06-27 09:58:39 +01:00
lucasfcosta
9375d85081 Improve handling for empty Strings on throws assertion 2016-06-26 20:06:11 -03:00
lucasfcosta
db1faba456 Throws assertion polishments for Assert interface 2016-06-25 17:21:05 -03:00
Grant Snodgrass
3fdb5423e7 Fix duplicate handling in members assertion 2016-06-24 20:50:16 -04:00
Grant Snodgrass
d0972d2999 Throw when non-existent property is read 2016-06-24 09:39:49 -04:00
Keith Cirkel
d08002ed88 Merge pull request #683 from lucasfcosta/throw-using-checkerror
Throw using checkError module
2016-06-24 10:12:13 +01:00
Grant Snodgrass
adf2b6cf78 Add ordered flag for members assertions 2016-06-12 13:32:50 -04:00
Grant Snodgrass
a1c5ff74c7 Fix chai.use as ES6 named export 2016-06-09 17:50:32 -04:00
lucasfcosta
b9436a9e56 Refactor throw to use checkError module 2016-06-08 20:29:45 -03:00
Grant Snodgrass
16ef15b4ad Fix failing tests in IE 10 and 11 2016-05-15 09:52:39 -04:00
Lucas Vieira
7429954e9e Add .does as a no-op assertion, Fix #700 2016-05-07 01:12:08 -03:00
Lucas Vieira
60b03bc61e Add tests for no-ops chains 2016-05-07 01:12:02 -03:00
Eduard Bardají Puig
63ab713c15 Fix ownProperty on objects with no prototype 2016-04-24 18:20:36 -07:00
Tomáš Polomský
bdd558e43f Fix failure when custom inspect method is used
When custom inspect method is used and this method calls stylize test crashes.
Stylize method is documented for Node.js 4.x and 5.x.
2016-04-17 14:27:06 +02:00
meeber
ea2c7040ab Refactor global.err to test error properties
- Add feature https://github.com/chaijs/chai/issues/675
- Fix bug https://github.com/chaijs/chai/issues/648
- Allow object overload of global.err's second argument
- Combine global.err and window.err into one file and function
- Add tests for global.err
2016-04-12 06:58:09 -04:00
meeber
e22835116c Fix bug when asserting some valid ES6 keys
- Resolution of https://github.com/chaijs/chai/issues/674
- Add compareByInspect utility for use with assertKeys sorts
- Add getOwnEnumerableProperties utility
- Add getOwnEnumerablePropertySymbols utility
- Add Symbol support to the inspect utility
- Add tests to utilities, should, expect, and assert
2016-04-11 13:40:34 -04:00
meeber
e380173aed Fix bug when testing Symbol equality with should syntax (#669) 2016-04-08 06:17:30 -04:00
Tobias Bieniek
58532d9b06 test: Add "overwriteMethod" stack trace tests 2016-04-04 16:06:31 +02:00
Tobias Bieniek
c4f522f6fb test: Add "overwriteProperty" stack trace tests 2016-04-04 13:27:24 +02:00
Tobias Bieniek
cf378e4782 test/configuration: Use describe('includeStack') block 2016-04-04 13:27:24 +02:00
Jesús Leganés Combarro
85fb7a6583 deepStrictEqual
Added `deepStrictEqual` as an alias for `deepEqual`
2016-03-31 13:21:47 +02:00
Homa Wong
384f88c3f6 Merge branch 'master' into patch-1 2016-03-27 16:34:11 -07:00
Keith Cirkel
bf1e0bff33 Merge pull request #633 from lucasfcosta/keys-for-maps-and-sets
Keys for maps and sets
2016-03-27 23:28:11 +01:00
Homa Wong
7e026ad170 Update expect.js
The err() takes only two params
2016-03-26 23:14:28 -07:00
lucasfcosta
67a3ca5109 Tests to check if addMethod returns a new Assertion instance 2016-03-20 16:14:48 -03:00
lucasfcosta
c654360e68 Keys assertions on assert interface (and tests) 2016-03-09 19:48:28 -03:00
lucasfcosta
1b308587b0 Tests for keys assertion on maps and sets 2016-03-09 19:48:28 -03:00
lucasfcosta
f286e0e6b3 Keys assertion can operate on Maps and Sets 2016-03-09 19:48:28 -03:00
lucasfcosta
10a0bbcc6a by assertion tests 2016-02-22 17:17:38 -03:00
Steven Peng
c3f3e94cc5 Convert keys to strings 2016-02-16 21:07:32 -08:00
lucasfcosta
e778cee15d Code style fixes related to function for value on inc, dec and changes 2016-02-11 18:56:29 -02:00
lucasfcosta
f158523321 Increases and Decreases assertions accepting function for value 2016-02-11 18:56:29 -02:00
lucasfcosta
0fe471885c Change accepts a function as object 2016-02-11 18:56:29 -02:00
qbolec
ae4b5f97c7 Added includeDeepMembers 2016-01-10 13:51:17 +01:00
Jurko Gospodnetić
568fc1ae0b fix error message tag substitution
String.prototype.replace() had some extra undesireable substitution behaviour
when it replaces a tag with a string containing some internal tags like `$$`,
or `$'`.

For more detailed information see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
2015-12-14 15:13:03 +01:00
Jurko Gospodnetić
f73d026f28 split up getMessage() tests 2015-12-14 15:04:58 +01:00
Droogans
b474ceee54 feat(matchers): Allow for objects in oneOf 2015-10-15 15:02:43 -05:00
Droogans
179d4701b8 feat(matchers): Add value-in-list assertion
Adds a way to test if a value appears in a flat list. Compliments
`include.members` to reverse the order of the input. Now the list
appears in the assertion, as opposed to the `expect`.

Closes #532
2015-10-12 22:18:24 -05:00
root
7fe23e9799 Added approximately alias to close to 2015-10-04 01:49:25 -04:00
Jérémie Astori
1f8c65135d Remove multi-type support for a/an assertion 2015-09-12 13:04:56 +00:00
Jérémie Astori
675b51b3ad Add a utility to enforce allowed types tested by an assertion 2015-09-12 12:59:51 +00:00
Jérémie Astori
0acb2ec8f5 Use new feature of a/an assertion to check type of tested object when using include assertion 2015-09-12 10:14:01 +00:00
Jérémie Astori
d27ceb54a4 Improve message of multi-type a/an assertions 2015-09-12 10:14:01 +00:00
Jérémie Astori
5eb39067ad Add support of multiple types in an/a assertions for the BDD API, with naive message 2015-09-12 10:14:01 +00:00
Jérémie Astori
cf0e3a5677 Check that expected type for include is an array, an object, or a string, in a naive way 2015-09-12 10:14:01 +00:00
Keith Cirkel
cf9f5d99d7 Merge pull request #512 from dereke/master
fixed expect('').to.contain('') so it passes
2015-09-11 22:20:30 +01:00
kpdecker
b6b84e5631 Fix stack trace tracking for property asserts
The ssfi parameter was not being updated for these methods, which ended up causing the trace to be omitted.

Fixes #358
2015-09-08 02:15:47 -05:00
Derek Ekins
eaba0be444 fixed expect('').to.contain('') so it passes 2015-09-01 13:59:39 +01:00
Keith Cirkel
a42ac436bb Merge pull request #496 from astorije/astorije/frozen-errors
Make sure TypeErrors thrown by frozen are caught
2015-08-10 10:13:16 +01:00
Jérémie Astori
1cc56c88eb Remove some trailing whitespaces 2015-07-26 19:43:02 +00:00
Jérémie Astori
ffc59fccd5 Make sure TypeErrors thrown by extensible are treated in a ES6 way and test these 2015-07-26 19:42:46 +00:00
Jérémie Astori
9b71590fe3 Make sure TypeErrors thrown by sealed are treated in a ES6 way and test these 2015-07-26 19:31:48 +00:00
Jérémie Astori
eae67c0d5c Make sure TypeErrors thrown by frozen are treated in a ES6 way and test these 2015-07-26 17:43:48 +00:00
Wraithan (Chris McDonald)
3c681e2dce isAtLeast, isAtMost assertions added to assert interface 2015-07-24 09:25:56 -07:00
Cezary Kluczyński
5bd86c2b38 isNotTrue, isNotFalse assertions added 2015-07-20 19:29:04 +02:00
Jérémie Astori
3be31001d1 Add tests for throws aliases 2015-07-18 23:14:45 +00:00
Jérémie Astori
11aa743472 Add aliases (and tests) for assert.ok and assert.notOk to match the other isSomething assertions 2015-07-18 23:14:45 +00:00
Jérémie Astori
40dc848842 Add tests for frozen, sealed and extensible aliases 2015-07-18 23:08:12 +00:00
Brad Cypert
a5687a2648 Added support for NaN. Tests included. 2015-07-16 10:18:54 -07:00
matthewlucock
63a89f6967 Assertions to test if objects are frozen 2015-07-12 22:57:42 +10:00
matthewlucock
1486d41b96 Assertions to test if objects are sealed 2015-07-12 22:57:26 +10:00
matthewlucock
4c7926f5f0 Assertions to test if objects are extensible 2015-07-12 22:56:15 +10:00
root
3048c06f00 Assert ifError now throws the error passed in, to keep it consistent with node's assert.ifError 2015-05-29 20:37:29 +01:00
Keith Cirkel
57a5bfd6f2 Merge pull request #451 from csnover/browserify
Switch to use Browserify for builds
2015-05-29 20:17:14 +01:00
⅕ Zander
91f57e9598 Add tests for undefined property error 2015-05-29 02:16:22 -04:00
Colin Snover
afc8aa1d50 Switch to use Browserify for builds
Fixes #362.
2015-05-27 13:04:16 +00:00
James Kyle
f1572d64d2 Add Assertion alias: matches => match. Resolves #438 2015-05-04 08:50:34 -07:00
Jordan Harband
517d46392f Use a regex to account for property ordering issues across engines. 2015-04-07 09:16:10 -07:00
Jordan Harband
8b6a3ccb31 Add ownPropertyDescriptor assertion. 2015-03-26 14:08:53 -07:00
Kaito Udagawa
704670a23b Feature: backslash-escaping in .deep.property
This commit includes:
* getPathInfo handles escaping `.[]`
* Documentation added to `.property`
* Documentation added to `.getPathInfo`
* Test cases for `.property`
* Test cases for `.deep.property`
* Test cases for `.getPathInfo`
Note that the input of `.getPathInfo` assumed to match the following:
/^(?:(?:\\[.\[\]]|[^.\[\]])+|\[\d+\])(?:\.(?:\\[.\[\]]|[^.\[\]])+|\[\d+\])$/
2015-03-18 21:57:03 +09:00
Kaito Udagawa
b6e1b573e0 Escaping dot should be taken in deep property
* removing backslash prior to "."
* test case: "foo\\.bar" names {"foo.bar": "baz"}
2015-03-17 19:39:14 +09:00
root
da2ec4a1d4 No longer using eval on assert operator #386 2015-03-08 13:18:49 -04:00
eldritch fossicker
57ef36621f fix indexing into array with deep propery
* added unit test to expect with code from documentation
* added default to res in _getPathValue
2015-03-02 14:00:46 -06:00
Keith Cirkel
9b25d0c524 Merge pull request #356 from Soviut/master
Added fail() method to Should and Expect interfaces
2015-02-10 23:41:58 +00:00
Ian Zamojc
c2f9e430d9 fail method added directly to expect 2015-02-10 16:50:31 -05:00
Gregg Lind
4f40b37356 fix #359. Add `.keys(object)
- `.keys(object)n => .keys(Object.keys(Object)`
- added exceptions for 'if first arg is non-string, then it must be only
arg.  => `.keys(Array|Object, ...)`

Warning:  `Object.keys` must exist on systems to use this functionality.
2015-02-09 09:16:01 -06:00
Gregg Lind
68f3c02f07 Fix #359 keys() sorts input unexpectedly 2015-02-05 19:36:09 -06:00
Ian Zamojc
61d8718c69 added fail() method to expect interface 2015-01-30 16:00:47 -05:00
Ian Zamojc
9080562c9a using proper error checking method for should 2015-01-30 16:00:47 -05:00
Ian Zamojc
d353bf7bc5 added should.fail() method 2015-01-30 16:00:46 -05:00
toastynerd
498fe95126 add the which chain method as per issue #347 2015-01-22 09:07:59 -08:00
Chris Polis
051fd95d88 cleaned out .by for #333 2015-01-02 10:13:44 -08:00
Chris Polis
cb1c33b5d8 updated change to work w/ non-number values + tests 2014-12-29 09:45:25 -08:00
Chris Polis
be67119616 assert tests for change,increase,decrease 2014-12-27 17:13:22 -08:00
Chris Polis
c44a5133f9 expect/should tests for change,increase,decrease 2014-12-27 17:10:59 -08:00
Chris Jones
e0e06082ea Added the all and any flags for keys assertion, with all being the default behavior
Extended keys documentation and set bools instead of changing flags in the keys assertion

Miswrote in keys documentation, corrected mistake

Edited documentation for keys to better match how it interacts with contains and have
2014-12-03 18:00:42 -05:00
Chris Jones
e3e170d3e0 Fixes issue #291, adds assert.sameDeepMembers 2014-12-02 19:38:07 -05:00
Keith Cirkel
49e003c1f2 Merge pull request #311 from cjqed/305-above-below-on-assert
Issue #305 fixed, added assert.isAbove and assert.isBelow
2014-12-02 22:56:11 +00:00
Keith Cirkel
7de269af35 Merge pull request #308 from prodatakey/hasproperty
Fix properties with `undefined` value pass property assertion
2014-12-02 22:55:14 +00:00
Chris Jones
e8e8caf4c2 Issue #305 fixed, added assert.isAbove and assert.isBelow 2014-11-29 01:52:00 -05:00
Joshua Perry
dd51594075 More unit tests for new utility functions 2014-11-21 12:27:26 -07:00
Joshua Perry
2d22f4534e Refactor common functionality, document, test 2014-11-20 16:48:56 -07:00
Joshua Perry
8cdb7b1d76 Refactor if statement out 2014-11-18 17:42:30 -07:00
Joshua Perry
c4b0d18829 Small unit test fix 2014-11-18 17:25:39 -07:00
Joshua Perry
7d466b2d37 Handle array indexing terminating paths 2014-11-18 17:18:00 -07:00
Joshua Perry
32826c06df Fix properties with undefined value pass property assertion 2014-11-15 16:29:57 -07:00
Keith Cirkel
b826feba51 Revert "Allows writing lint-friendly tests" 2014-11-13 11:58:50 +00:00
Keith Cirkel
828f48148f Merge pull request #297 from prodatakey/noopchainfunc
Allows writing lint-friendly tests
2014-11-10 09:44:19 +00:00
Julien Wajsberg
84cba222d1 Fix #299: the test is defining global variables 2014-11-06 12:09:55 +01:00
Joshua Perry
867563b0db Add a couple more unit tests 2014-11-05 10:14:28 -07:00
Joshua Perry
b4c0424ffb Add unit tests for chained terminating property asserts 2014-11-05 07:30:45 -07:00
David da Silva
edef912f41 why not more assertions 2014-11-01 20:24:59 +01:00
David da Silva
627e4b0096 added test for inspecting -0 2014-11-01 20:19:27 +01:00
Joshua Perry
cc1357d344 Change test to not trigger argument bug 2014-10-13 18:00:07 -06:00
Joshua Perry
4b0c0b6222 Allows writing lint-friendly tests
This makes the final assertion checks noop functions so that they can be formatted like function calls. This keeps linters (JSLint/JSHint) off our back for having an inop expression.

Completes #41
2014-10-13 16:31:17 -06:00
Jake Luer
834fd5b0dd Merge pull request #268 from charlierudolph/cr-lazyMessages
Allow messages to be functions
2014-09-29 18:18:25 -04:00
Jake Luer
3e692e6d04 Merge pull request #279 from mohayonao/fix-closeTo
fix: closeTo should check value's type before assertion
2014-09-29 18:15:53 -04:00
Christopher Hiller
6d6f03d2d2 resolves #255: upgrade mocha 2014-09-11 22:54:56 -07:00
mohayonao
11fe70ef82 assert: .closeTo() verify value's type before assertion 2014-07-16 09:50:45 +09:00
charlierudolph
216ad26aa1 Allow messages to be functions 2014-06-08 14:00:42 -07:00
Jake Luer
1df11d0027 util: [getActual] select actual logic now allows undefined for actual. Closes #183 2014-03-18 09:35:43 -04:00
Roman Masek
9e5f9ffd3b Fix issue #166 - configurable threshold in objDisplay. 2014-03-18 08:20:15 +01:00
Roman Masek
7dd05e3b7a Move configuration options to config.js. 2014-03-18 08:18:11 +01:00
Jake Luer
07b34c7b49 Merge pull request #233 from Empeeric/master
ssfi as it should be
2014-02-25 12:43:59 -05:00
leider
cb910afc52 additional test finds incomplete implementation 2014-02-09 14:41:03 +01:00
leider
7352fdeec7 fixing #239 (without changing chai.js) 2014-02-09 13:31:45 +01:00
Refael Ackermann
62d9ceb208 ssfi as it should be 2014-01-30 10:23:19 +02:00
Duncan Beevers
ec62443b7c Deep equality check for collection membership 2014-01-29 19:08:16 -06:00
Jake Luer
c3c1fccc2d assert: .throws() returns thrown error. Closes #185 2014-01-29 17:22:29 -05:00
Jake Luer
b01eba75c9 assert: .fail() parameter mismatch. Closes #206 2014-01-29 16:23:04 -05:00
Veselin
a01e40b2cc Merge pull request #230 from jkroso/include
support `{a:1,b:2}.should.include({a:1})`
2014-01-27 07:11:45 -08:00
Veselin Todorov
764d00e73c Remove jscoverage 2014-01-26 08:38:49 +02:00
Jake Rosoman
acbf04dad2 handle negation correctly 2014-01-05 15:26:33 +13:00
Jake Rosoman
75bb2b68f6 add failing test case 2014-01-05 14:33:52 +13:00
Jake Rosoman
2715e95abc support {a:1,b:2}.should.include({a:1}) 2014-01-05 14:10:14 +13:00
Veselin Todorov
f3ebb09a58 Merge pull request #224 from vbardales/master
Return error on throw method to chain on error properties
2014-01-02 10:50:25 -08:00
Virginie BARDALES
2bb0ff2ab7 return error on throw method to chain on error properties, possibly different from message 2013-12-19 10:23:46 +01:00
Max Edmands
2127525933 util: add overwriteChainableMethod utility (for #215) 2013-11-30 09:31:06 -08:00
Max Edmands
4ce3d420e2 test: make it possible to run utilities tests with --watch 2013-11-28 13:54:17 -08:00
Andrei Neculau
b1c7d710a4 test: add tests for throwing custom errors 2013-10-23 23:48:48 +02:00
Andrei Neculau
e174212d0f test: updated for the new assertion errors 2013-10-23 23:06:39 +02:00
Jake Luer
8a2e00b486 test: [sauce] use karma@canary to prevent timeouts 2013-09-17 23:12:16 -04:00
Jake Luer
a8f94bdcbb test: [karma] use karma phantomjs runner
- tests refactored as bdd instead of tdd
- removed test/browser bootstraps
- add karma-runner
2013-09-17 17:22:36 -04:00
Jake Luer
7bc580910e core: [assertion-error] replace internal assertion error with dep 2013-06-17 15:27:50 -04:00
Domenic Denicola
7c72e673f4 Fix utils.inspect with custom object-returning inspect()s.
This code is lifted from the latest node utils.js: 896b2aa707/lib/util.js (L205-L209)

Without it, if an object contains another object whose custom `inspect()` method returns a non-string, `utils.inspect` gets confused and tries to do `nonString.indexOf`.

This fixes domenic/chai-as-promised#32, where Chai as Promised was trying to call `utils.inspect` on an `AssertionError` which contained as its "actual" property a Q promise. Since Q promises have custom `inspect` methods that return objects, not strings, this was triggered.
2013-06-13 23:12:58 -04:00
Bartvds
774a723bff replaced tabs with 2 spaces 2013-06-09 01:31:26 +02:00
Bartvds
080702ac87 added assert.notOk() 2013-06-08 18:16:44 +02:00
George Kats
044dcff68d Fix comparison objects.
Regexp and Date objects can to be deep equal to objects with the same type.
2013-06-06 00:53:34 +03:00
George Kats
2c4da4a91a Add test for different RegExp flags. 2013-06-05 23:26:42 +03:00
George Kats
f62eb19a66 Add test for regexp comparison. 2013-06-05 02:14:53 +03:00
Jake Luer
019bb07637 assert: [(not)include] throw on incompatible haystack. Closes #142 2013-04-29 19:30:51 -04:00
Jake Luer
8f8d7425a5 assert: [notInclude] add assert.notInclude. Closes #158 2013-04-29 19:03:53 -04:00
Jake Luer
30784962da Merge branch 'master' of github.com:chaijs/chai
* 'master' of github.com:chaijs/chai:
  giving members a no-flag assertion
  Code review comments - changing syntax
  Code review comments
  Adding members and memberEquals assertions for checking for subsets and set equality. Implements chaijs/chai#148.
  Restore the `call` and `apply` methods of Function when adding a chainable method.
2013-04-29 17:18:34 -04:00
Jake Luer
e5e3a4fa42 test: [assert] deep equal ordering 2013-04-29 17:18:22 -04:00
Nick Heiner
244fa51336 giving members a no-flag assertion 2013-04-23 11:12:23 -04:00
Nick Heiner
22e2a78a4e Code review comments - changing syntax 2013-04-14 19:07:12 -04:00
Nick Heiner
078da00be3 Adding members and memberEquals assertions for checking for subsets and set equality. Implements chaijs/chai#148. 2013-04-14 17:58:07 -04:00