Skip to content

Commit

Permalink
fix: resolve with full response
Browse files Browse the repository at this point in the history
  • Loading branch information
hfreire committed Jun 23, 2017
1 parent b59bdf2 commit e57666b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/happn-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class HappnWrapper {

return this._getRequestCircuitBreaker.exec(options)
.then((response) => handleResponse(response))
.then(({ data }) => data)
}

getAccount () {
Expand All @@ -154,7 +153,6 @@ class HappnWrapper {

return this._getRequestCircuitBreaker.exec(options)
.then((response) => handleResponse(response))
.then(({ data }) => data)
}

getUpdates (limit = 10, offset = 0) {
Expand All @@ -174,7 +172,6 @@ class HappnWrapper {

return this._getRequestCircuitBreaker.exec(options)
.then((response) => handleResponse(response))
.then(({ data }) => data)
}

sendMessage () {
Expand Down
32 changes: 14 additions & 18 deletions test/happn-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ describe('Happn Wrapper', () => {
describe('when getting recommendations', () => {
const userId = 'my-user-id'
const statusCode = 200
const data = {}
const body = { data: {} }
const body = {}
const response = { statusCode, body }

beforeEach(() => {
Expand Down Expand Up @@ -178,8 +177,8 @@ describe('Happn Wrapper', () => {

it('should resolve with response body as data', () => {
return subject.getRecommendations()
.then((_data) => {
_data.should.be.eql(data)
.then((data) => {
data.should.be.eql(body)
})
})
})
Expand Down Expand Up @@ -209,8 +208,7 @@ describe('Happn Wrapper', () => {
describe('when getting account', () => {
const userId = 'my-user-id'
const statusCode = 200
const data = {}
const body = { data }
const body = {}
const response = { statusCode, body }

beforeEach(() => {
Expand All @@ -237,17 +235,16 @@ describe('Happn Wrapper', () => {

it('should resolve with response body as data', () => {
return subject.getAccount()
.then((_data) => {
_data.should.be.eql(data)
.then((data) => {
data.should.be.equal(body)
})
})
})

describe('when getting user', () => {
const userId = 'my-user-id'
const statusCode = 200
const data = {}
const body = { data }
const body = {}
const response = { statusCode, body }

beforeEach(() => {
Expand All @@ -273,8 +270,8 @@ describe('Happn Wrapper', () => {

it('should resolve with response body as data', () => {
return subject.getUser(userId)
.then((_data) => {
_data.should.be.eql(data)
.then((data) => {
data.should.be.equal(body)
})
})
})
Expand All @@ -299,8 +296,7 @@ describe('Happn Wrapper', () => {
describe('when getting update', () => {
const userId = 'my-user-id'
const statusCode = 200
const data = {}
const body = { data }
const body = {}
const response = { statusCode, body }

beforeEach(() => {
Expand Down Expand Up @@ -342,8 +338,8 @@ describe('Happn Wrapper', () => {

it('should resolve with response body as data', () => {
return subject.getUpdates()
.then((_data) => {
_data.should.be.eql(data)
.then((data) => {
data.should.be.eql(body)
})
})
})
Expand Down Expand Up @@ -397,8 +393,8 @@ describe('Happn Wrapper', () => {

it('should resolve with response body as data', () => {
return subject.like(userIdToLike)
.then((_data) => {
_data.should.be.equal(body)
.then((data) => {
data.should.be.equal(body)
})
})
})
Expand Down

0 comments on commit e57666b

Please sign in to comment.