-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adding dotNotation property and test #48
Changes from 1 commit
9ba84d9
ef49df7
afc72c1
1af1a81
4fa19ca
dd8deeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var QUnit = require("steal-qunit"); | ||
|
||
var set = require('../set-core'), | ||
props = require("../props"); | ||
|
||
QUnit.module("can-set props.boolean"); | ||
|
||
/* | ||
* For the dotNotation prop, we define sets like so: | ||
* | ||
* For a property 'n.p', with value 'IL' | ||
* x ∈ X | x.n.p = 'IL' | ||
* | ||
*/ | ||
test('dotNotation set membership', function() { | ||
/* | ||
* For a property 'n.p', with value 'IL' | ||
* x ∈ X | x.n.p == 'IL' | ||
*/ | ||
var prop = props.dotNotation('n.p'), | ||
alg = new set.Algebra(prop), | ||
res = alg.has({'n.p': 'IL'}, {n:{p:'IL'}}); | ||
ok(res, "object with nested property is member of set using dotNotation"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was also looking for a way to test the unpredictable argument order handling. Tried an alg.has with the arguments reversed, and my comparator returns true in that case, but alg.has was still returning false. I'm guessing another 'default' prop was doing its own check and returning false. Anyone have an idea how I could test that via an algebra operation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I probably should understand this, but I don't, what causes the argument order to be unpredictable? |
||
|
||
/* | ||
* For a property 'n.p', with value 'IL' | ||
* x ∉ X | x.n.p != 'IL' | ||
*/ | ||
res = alg.has({'n.p': 'IL'}, {n:{p:'MI'}}); | ||
notOk(res, "object with nested property not a member of set using dotNotation"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you include a test for more than 1 level of nesting like
address.state.city
?