Skip to content
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

[REGRESSION] Route.send is no longer unit testable #11663

Closed
poteto opened this issue Jul 6, 2015 · 1 comment · Fixed by #11664
Closed

[REGRESSION] Route.send is no longer unit testable #11663

poteto opened this issue Jul 6, 2015 · 1 comment · Fixed by #11664
Assignees
Milestone

Comments

@poteto
Copy link

poteto commented Jul 6, 2015

Tested on 1.13.3

Unit testing a route's actions via route.send is now broken, as this.router (https://github.com/emberjs/ember.js/blob/v1.13.3/packages/ember-routing/lib/system/route.js#L1082) refers to the service (router.router is undefined) and the else conditional never hits.

Sample test to reproduce:

// app/foo/route.js
import Ember from 'ember';

const set = Ember.set;

export default Ember.Route.extend({
  actions: {
    update(key, value) {
      set(this, key, value);
    }
  }
});

// tests/unit/foo/route-test.js
import Ember from 'ember';
import { moduleFor, test } from 'ember-qunit';

const get = Ember.get;

moduleFor('route:foo', 'Unit | Route | foo');

test('action `foo` does something', function(assert) {
  const expectedResult = 'bar';
  const route = this.subject();

  route.send('update', 'foo', 'bar'); // TypeError: Cannot read property 'trigger' of undefined

  assert.equal(get(route, 'foo'), expectedResult, 'it sets the value');
});

Related – #9820

@rwjblue
Copy link
Member

rwjblue commented Jul 6, 2015

Should be fixed with #11664.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants