Skip to content

Commit

Permalink
add test to highlight #19307
Browse files Browse the repository at this point in the history
  • Loading branch information
sly7-7 committed Mar 4, 2021
1 parent b64b292 commit 7f40e54
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions packages/ember/tests/routing/substates_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { RSVP } from '@ember/-internals/runtime';
import { Route } from '@ember/-internals/routing';
import Controller from '@ember/controller';

import { moduleFor, ApplicationTestCase, runTask } from 'internal-test-helpers';

let counter;
Expand Down Expand Up @@ -193,6 +195,77 @@ moduleFor(
});
}

['@test Enter loading route with correct query parameters'](assert) {
let deferred = RSVP.defer();

this.router.map(function () {
this.route('dummy');
});

this.add(
'route:dummy',
Route.extend({
model() {
step(assert, 1, 'DummyRoute#model');
return deferred.promise;
},
})
);

this.add(
'controller:application',
class extends Controller {
queryParams = ['qux'];

qux = 'initial';
}
);

this.add(
'route:loading',
Route.extend({
setupController() {
step(assert, 2, 'LoadingRoute#setupController');
},
})
);
this.addTemplate('dummy', 'DUMMY');

return this.visit('/?qux=updated').then(() => {
assert.equal(
this.getController('application').qux,
'updated',
'the application controller has the correct qp value'
);

let promise = this.visit('/dummy?qux=updated').then(() => {
let text = this.$('#app').text();

assert.equal(text, 'DUMMY', `dummy template has been rendered`);
assert.equal(
this.getController('application').qux,
'updated',
'the application controller has the correct qp value'
);
});
assert.equal(this.currentPath, 'loading', `loading state entered`);
assert.equal(
this.currentURL,
'/dummy?qux=updated',
`during loading url reflect the correct state`
);
assert.equal(
this.getController('application').qux,
'updated',
'the application controller has the correct qp value'
);

deferred.resolve();

return promise;
});
}

['@test Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present'](
assert
) {
Expand Down

0 comments on commit 7f40e54

Please sign in to comment.