Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions app/routes/notifications.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class NotificationsRoute extends Route {
@service router;

queryParams = {
dev: {
refreshModel: false,
},
};

beforeModel(transition) {
if (transition?.to?.queryParams?.dev !== 'true') {
this.router.transitionTo('/page-not-found');
}
}
}
export default class NotificationsRoute extends Route {}
47 changes: 0 additions & 47 deletions tests/unit/routes/notifications-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,4 @@ module('Unit | Route | notifications', function (hooks) {
const route = this.owner.lookup('route:notifications');
assert.ok(route, 'The route exists');
});

test('it should redirect to "/page-not-found" page when dev flag is not present', function (assert) {
assert.expect(3);

const route = this.owner.lookup('route:notifications');

let transitionToCalls = [];

route.router = {
transitionTo(routeName) {
transitionToCalls.push(routeName);
},
};

route.beforeModel({
to: {
queryParams: { dev: 'false' },
},
});
assert.strictEqual(
transitionToCalls[0],
'/page-not-found',
'Redirected to /page-not-found when dev=false',
);

route.beforeModel({
to: {
queryParams: {},
},
});
assert.strictEqual(
transitionToCalls[1],
'/page-not-found',
'Redirected to /page-not-found when dev flag is missing',
);

route.beforeModel({
to: {
queryParams: { dev: 'true' },
},
});
assert.strictEqual(
transitionToCalls.length,
2,
'Did not redirect when dev=true',
);
});
});