-
Notifications
You must be signed in to change notification settings - Fork 21
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
Improve compatibility with Ember.ArrayProxy. Fixes #109 #110
Conversation
a088e3a
to
5bcd661
Compare
5bcd661
to
ff2ba4f
Compare
I'm going to make some changes to ember-macro-test-helpers so it is easier to test with different base classes. |
With kellyselden/ember-macro-test-helpers#62, you should be able to structure your tests: let { subject } = compute({
baseClass: Ember.ArrayProxy,
computed: computed('[]', getCallback)
});
getCallback.reset();
subject.pushObject('foo');
assert.deepEqual(getCallback.args, [['foo']]); The individual functions changed should get unit tested too. |
@kellyselden Great! I'll take a whack at it. I didn't change the behavior of any functions, per se, just tweaked how they achieve the same results. I think the existing bevy of unit tests should be sufficient? I'll at least add a new unit test for getValue since it has a bit of new behavior. |
ff2ba4f
to
09f1d04
Compare
@kellyselden Okay, please take a look! The sinon stub is weirdly wrapping the ArrayProxy argument in an array; it looks like It's currently pointing at your ember-macro-test-helpers feature branch so I can fix that if/when you decide to release that add-on with the new baseClass feature. Just let me know. |
09f1d04
to
88a111f
Compare
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.
I think additional tests are needed:
tests\unit\collapse-key-test.js
collapseKey('@each.bar')
collapseKey('[]')
tests\unit\normalize-array-key-test.js
normalizeArrayKey('@each.prop')
normalizeArrayKey('[]')
Then it should be good to go.
@@ -10,5 +11,9 @@ export default function({ context, macro, key } = {}) { | |||
return macro; | |||
} | |||
|
|||
if (isBlank(macro)) { |
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 comment under what conditions this will hit?
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.
Done.
Released that branch in [email protected] |
88a111f
to
69caca9
Compare
@kellyselden Thanks for the hand-holding, and thanks for being clear on what you want to see before accepting this patch. I really appreciate it. Here's the latest round of changes, submitted for your approval! |
69caca9
to
ec47d87
Compare
ec47d87
to
cb6ad38
Compare
@kellyselden Any further feedback on this? |
Sorry for letting this sit so long. Going to try to review today. |
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.
A simplification and module import updates are needed. Thanks in advance.
} | ||
|
||
if (atEachIndex === 0) { | ||
return ['']; |
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.
I tried this branch out, and I think you want to return [];
in this case. Then you can remove the extra blank handling from get-value.js
.
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.
Hrrm, I can't get this to work. With this change, collapsedKeys()
returns an empty array, then bundledKeys
in createArgs()
is an empty array, and getValue()
never gets called, so there's no logic anywhere that sets the value at that key to context
. What am I missing? I agree that return [''];
is kind of clumsy.
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.
Hmm I will keep digging, maybe I'm wrong.
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.
So I messed with it a bit, and I was wrong. Your empty string is the best way to handle this. Thanks for schooling me!
tests/integration/computed-test.js
Outdated
@@ -4,6 +4,8 @@ import { module } from 'qunit'; | |||
import sinon from 'sinon'; | |||
import compute from 'ember-macro-test-helpers/compute'; | |||
import namedTest from '../helpers/named-test'; | |||
import ArrayProxy from 'ember-controller/proxy'; |
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.
This will need to update to new module API that @Turbo87 added please.
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.
Done.
cb6ad38
to
b971021
Compare
Finally this bad boy is merged! |
Huzzah! Thanks Kelly! |
Any new test suggestions? Not quite sure how to approach it.