Skip to content

Commit

Permalink
test: account.fetch() includes .profile
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jul 25, 2016
1 parent b4d096b commit 94998d3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
12 changes: 11 additions & 1 deletion test/fixtures/fetch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,15 @@
}
}
}
}
},
"included": [
{
"id": "abc4567-profile",
"type": "profile",
"attributes": {
"fullName": "Docs Chicken",
"favoriteClothing": "Hoodie"
}
}
]
}
11 changes: 9 additions & 2 deletions test/integration/fetch-url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ test('account.fetch() and account.profil.fetch()', function (t) {
})

var apiMock = nock('http://localhost:3000')
.get('/session/account')
.get('/session/account?include=profile')
.reply(200, require('../fixtures/fetch.json'))
.get('/session/account/profile')
.reply(200, require('../fixtures/fetch-profile.json'))

account.fetch()

.then(function (accountProperties) {
t.same(accountProperties, {id: 'abc4567', username: 'john-doe'})
t.same(accountProperties, {
id: 'abc4567',
username: 'john-doe',
profile: {
fullName: 'Docs Chicken',
favoriteClothing: 'Hoodie'
}
})

return account.profile.fetch()
})
Expand Down
2 changes: 1 addition & 1 deletion test/integration/unauthenticate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('unauthenticate state within account.fetch()', function (t) {
})

nock('http://example.de')
.get('/session/account')
.get('/session/account?include=profile')
.reply(401, errorMessage)

var account = new Account({url: 'http://example.de'})
Expand Down
10 changes: 6 additions & 4 deletions test/unit/fetch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ test('fetch', function (t) {
}, 'path')

t.deepEqual(internals.fetchProperties.lastCall.arg, {
url: 'http://example.com/session/account',
url: 'http://example.com/session/account?include=profile',
sessionId: 'abc4567',
path: 'path'
path: 'path',
include: 'profile'
}, 'calls fetchProperties with account url')

simple.restore()
Expand Down Expand Up @@ -52,9 +53,10 @@ test('fetch with undefined path', function (t) {
})

t.deepEqual(internals.fetchProperties.lastCall.arg, {
url: 'http://example.com/session/account',
url: 'http://example.com/session/account?include=profile',
sessionId: 'abc45678',
path: undefined
path: undefined,
include: 'profile'
}, 'calls fetchProperties with account url and non-string path')

simple.restore()
Expand Down

0 comments on commit 94998d3

Please sign in to comment.