-
-
Notifications
You must be signed in to change notification settings - Fork 145
Conversation
* @param {any} oldData - The old data to compare | ||
* @returns {boolean} The data has changed. | ||
*/ | ||
function dataChanged(newData, oldData) { |
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.
Beautiful, thank you!
src/components/Store.react.js
Outdated
const oldNull = R.isNil(old); | ||
const newNull = R.isNil(data); | ||
const oldNull = R.isNil(oldData); | ||
const newNull = R.isNil(newData); |
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.
isNil
catches both undefined
and null
- and mostly that distinction is moot because undefined
can't be sent via JSON, I guess. But we should be careful about it in objects, like {a: null} <-> {}
src/components/Store.react.js
Outdated
for (let i = 0; i < data.length; i++) { | ||
if (dataCheck(data[i], old[i])) { | ||
for (let i = 0; i < newData.length; i++) { | ||
if (dataChanged(newData[i], oldData[i])) { | ||
return true; | ||
} | ||
} | ||
} else if (R.contains(type, ['String', 'Number'])) { |
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.
'Boolean'
?
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.
Forgot about Boolean
in all this type checks, thanks!
Look like removing the falsy check in componentDidUpdate fixed the basic types changes. 🎉 I added a type check: if (type !== R.type(oldData)) {
return true;
} But it failed the test. Added Boolean to valid types. I'll add more edge cases test later. |
Can you say more? I don't see how that makes sense and I worry about remaining strange cases like #422 (comment) if this is omitted. |
Failure: |
9a3c0f5
to
0c9dfe4
Compare
self.assertEqual( | ||
assertion_text, | ||
self.driver.find_element_by_css_selector(selector).text | ||
text_equal |
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.
Ah, much nicer 🏆
In case anyone else hits this issue in the future: EC.text_to_be_present_in_element
does a substring match, not a full value match. Makes sense in retrospect, given its name... so if the previous value is a substring of the new value you're expecting in the element you can get a premature match 💥
6fb2e1e
to
7e276fe
Compare
@alexcjohnson Please review. |
test/test_integration.py
Outdated
('bool', False), | ||
('empty-dict', {}), | ||
('list-dict-1', [1, 2, {'data': [55, 66, 77], 'dummy': 'dum'}]), | ||
('list-dict-1', [1, 2, {'data': [111, 99, 88]}]), |
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.
Can you add the pathological items in my comments #422 (comment) and #422 (comment)? I think you fixed all those, but here's another one to add, that I think still fails:
dataChanged({a: 1, b: null}, {a: 1, c: 1}) // returns false, should be true
This is due to isNil
conflating undefined
and null
- come to think of it, is there really a reason to treat those as equivalent? Perhaps we can just change the null check to:
if (oldNull || newNull) {
return oldData !== newData; // which will distinguish null/undefined
}
@alexcjohnson Added the undef edge case and checking the data instead of the null fixed it. I think we're good now. |
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.
Excellent, thanks for the changes. 💃
Closes #422