-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test fails with undefined property #105
Comments
There are many issues related to Some time ago I have tried to add support for If i's to hard to fix JSON-Patch to work that way once again, I would re-describe applicable test cases, and add note on README what is the current behavior - make README in sync with spec. |
This commit only changes the test to the proposed solution to treating undefineds. I think that `jsonpatch.generate` should treat undefined exactly the same way it is treated in `json.stringify` and `jsonpatch.compare`. Every test should go the following path: var a = /*some object*/; observe(a); a.change = /*new value*/; var patches1 = generate(a); var b = (same object); var c = clone(b); b.change = /*new value*/ var patches2 = jsonpatch.compare(b, c); expect(patches1).toReallyEqual(/*expected patch*/); expect(patches1).toReallyEqual(patches2); toReallyEqual is a wrapper around Underscore isEqual, which knows the difference between undefined, null and unset values.
@warpech I fixed that, by start using |
Thanks @aloscha |
Ok, waiting for that |
Back to the original subject - first of all, we should stop using Jasmine's method expect({a: undefined}).toEqual({}); Secondly, I propose to use the following approach. Every test should go the following path (pseudocode):
The following commit implements that: ffaa563 @tomalec WDYT? In that commit, I don't use Jasmine's toEqual, but Underscore's isEqual (wrapped in a matcher called |
Changes are now merged to master. |
Two tests fails with
undefined
as a default property.First test:
it('
undefined
property is set to something', function() {var obj = {foo: undefined};
IMHO there need to be 'add' instead of 'replace'
Second test:
Here JSON-Patch create empty array as a result.
Also In that task needs to refactor readme:
@tomalec, @warpech what guys do you think about it?
The text was updated successfully, but these errors were encountered: