Skip to content

Creating a state service in an integration test requires a lot of boilerplate #45

@blimmer

Description

@blimmer

I have integration tests that get passed a state service, and it's a bit of a pain to set up because of the requirement to pass a string to the stateFor method.

For instance, I have a component x-foo and it renders x-bar in its template. Since x-foo creates the state object, x-bar gets passed the state component. In tests/integration/component/x-bar-test.js, I have to create the state service like this:

beforeEach(function() {
  const obj = Ember.Object.extend({
     initialStateObject: Ember.computed(function(){
        ... logic ...
     }),
     state: state('state', 'initialStateObject')
  }).create();

  this.set('stateObj', obj.get('state'));
});

it('does something', function() {
   this.render(hbs`{{x-bar stateObj=stateObj}}`);
   ... assertations ...
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions