tsatsmt
November 18, 2015, 10:47pm
1
I have a component text-console that I am trying to create an integration test for.
Ember v 1.13.8
Usage: {{text-console content=message.title}}
hbs:
{{content.text}}
How can I pass the message.title.
Here is the model
{message: {
title: {
text: ‘message text’
}
}}
When running this.set I get a message saying this.set is not defined
this.set(‘message.title’, {text: ‘sample message text’});
or
this.set(‘content’, message) where message = {title: {text: ‘some message’}}
Thanks for help.
this.render(hbs {{text-console content=message.title}}
);
I think (could be wrong) it is because your model is a POJO which doesn’t have a set
method - that’s why this.set
is undefined.
Try making your model an Ember.Object
instead of a POJO.
Alternatively, you could try setting the property using Ember.set(this, 'message.title')
or Ember.set(message, 'title')
.
tsatsmt
November 19, 2015, 4:34pm
3
Thanks for your response. I figured out what the issue was.
I had added needs in my module for component. Taking that out worked.
I believe the original problem was you needed to call this.set('message', { title: 'some message'})
to get the message object into your context.
needs
is for unit tests, not for component integration tests. you shouldn’t “need” needs
. Make sure you have integration: true
in your moduleForComponent call.