Testing routes can be done either by acceptance tests or unit tests. In this example, we'll create a simple unit test for a route.
In a new application, generate a new
students
route:$ ember g route students
This command will generate the route code for students.
Edit the students route information and add a new property:
// app/routes/students.js import Ember from 'ember'; export default Ember.Route.extend({ someText: 'someText' });
This route has a property called
someText
.Edit the
students-tests.js
file in thetests/unit/routes
folder:// tests/unit/routes/students-test.js import { moduleFor, test } from 'ember-qunit'; moduleFor('route:students', 'Unit | Route | students', { // Specify the other units that are required for this test. }); test('check prop and route exists', function(assert) { let route = this.subject(); assert.expect(3); assert.equal(route.get('someText'),'someText'); route.set('someText','otherText'); assert.equal...