-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
moduleForMixin? #15
Comments
What mixins are looked up on the container? Can't we just unit test these like any old js object? |
I guess I just need to come up with a good example of doing this. In this example I am needing to test a controller that uses the mixin in order to get the mixin functionality. The mixin references 'content' which resides on a controller that extends it. I suppose I could stub out a controller and have it extend the mixin under test. That's probably the best way, but if it is, should there be a shortcut to do this via ember-qunit? |
Mixins don't get registered on the container, so testing them is like testing any old non-ember thing. module('some mixin');
test('stuff', function() {
equal(MyMixin.foo(), 'foo');
}); |
we could still resolve them, which follows the same pattern as everything else.
|
@cavneb in your specific case (mixin is counting on properties being defined on the mixed-in context). I'd just create a dummy Ember.Object with those parts: http://jsbin.com/rehihane/1/edit Otherwise +1 to |
I think part of what we are wanting is shortcuts so people don't have to think about the setup any more than they have to. It would be ideal for moduleFor('mixin:foo') to do something like what @knomedia's jsbin shows. |
Yeah, I don't think one needs to assume that moduleFor is looking in the container, the structure makes it feel like you could look up any type of Ember Object and it should do the correct thing by default. |
It would be nice if |
+1 |
I think that the pattern that ember-cli uses for this is the right way to go: import Ember from 'ember';
import MySpecialMixin from '../mixins/my-special';
module('MySpecialMixin');
// Replace this with your real tests.
test('it works', function() {
var MySpecialObject = Ember.Object.extend(MySpecialMixin);
var subject = MySpecialObject.create();
ok(subject);
}); |
I thought this would be best too. Thanks for documenting it here, @rwjblue |
@rwjblue thanks for the demo on how to do this in ember-cli. I don't know if you're trying to prevent the docs from getting too unwieldy but I think this would be a great candidate to go on ember-cli.com. |
@SirZach - 'ember generate mixin foo' does this for you automatically. |
@rwjblue that's awesome. ember-cli continues to impress |
module('') appears to be deprecated in 0.2.0 |
0.2.0 of what project? |
@rwjblue
as a replacement |
@rwjblue I'm writing some unit tests for a mixin right now and I keep getting
How do I make sure I have computed properties, get/set available? |
I think we may need a moduleForMixin
The text was updated successfully, but these errors were encountered: