Skip to content

Commit 8022252

Browse files
committed
tests/dashboard: Use generic GET /api/v1/me route handler
1 parent 8bc4108 commit 8022252

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

tests/acceptance/dashboard-test.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ module('Acceptance | Dashboard', function (hooks) {
1919
});
2020

2121
test('shows the dashboard when logged in', async function (assert) {
22+
let user = this.server.create('user', {
23+
login: 'johnnydee',
24+
name: 'John Doe',
25+
26+
avatar: 'https://avatars2.githubusercontent.com/u/1234567?v=4',
27+
});
28+
29+
this.server.create('mirage-session', { user });
2230
window.localStorage.setItem('isLoggedIn', '1');
2331

2432
{
@@ -32,23 +40,6 @@ module('Acceptance | Dashboard', function (hooks) {
3240
this.server.create('version', { crate, num: '0.1.0' });
3341
}
3442

35-
this.server.get('/api/v1/me', {
36-
user: {
37-
id: 42,
38-
login: 'johnnydee',
39-
email_verified: true,
40-
email_verification_sent: true,
41-
name: 'John Doe',
42-
43-
avatar: 'https://avatars2.githubusercontent.com/u/1234567?v=4',
44-
url: 'https://github.com/johnnydee',
45-
},
46-
owned_crates: [
47-
{ id: 123, name: 'foo-bar', email_notifications: true },
48-
{ id: 56456, name: 'barrrrr', email_notifications: false },
49-
],
50-
});
51-
5243
this.server.get('/api/v1/me/updates', {
5344
versions: [
5445
{
@@ -145,7 +136,7 @@ module('Acceptance | Dashboard', function (hooks) {
145136
meta: { more: true },
146137
});
147138

148-
this.server.get('/api/v1/users/42/stats', { total_downloads: 3892 });
139+
this.server.get(`/api/v1/users/${user.id}/stats`, { total_downloads: 3892 });
149140

150141
await visit('/dashboard');
151142
assert.equal(currentURL(), '/dashboard');

0 commit comments

Comments
 (0)