2
votes

So, when you load up an Ember route, the model property on the route's controller gets set in one of two ways:

  • You pass the instantiated model directly to the controller via the {{link-to}} helper
  • The route's model hook fires, and you look up the model somehow.

These two options reflect the two different ways you can reach a route: via user action from an existing page, or via a URL accessed directly.

If I'm writing integration tests for a route, then, it seems like I need to explicitly test both scenarios (let's assume I'm not using Ember Data).

Would two separate integration tests make sense, or is there a single unit test I could write against the route or controller that made sure the controller received the right model in both cases?

1

1 Answers

0
votes

transitionTo('foo', 1); vs transitionTo('foo', { id: 1, name: 'foo'}); should cover both code paths.

If you grab an instance of a route you can do use those, or if you get an instance of a controller, you can use transitionToRoute. All of which return a promise which can be used for waiting on the transition to complete.