Skip to content

Commit

Permalink
Added sendPromise test for fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Crustum7 committed Dec 2, 2023
1 parent c8e22aa commit 5b12c01
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/server/test/unit/request_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,34 @@ describe('lib/request', () => {
expect(resp.status).to.eq(200)
})
})

it('can parse fixture option', function () {
const fixtureData = {
some: 'json',
foo: {
bar: 'baz',
},
}

nock('http://localhost:8080')
.matchHeader('accept', 'text/plain')
.post('/headers', fixtureData)
.reply(200)

return request.sendPromise({}, this.fn, (filePath, encoding) => {
return filePath === 'fakefixturename' && encoding === 'encoding' ? fixtureData : 'incorrect call'
}, {
url: 'http://localhost:8080/headers',
method: 'POST',
fixture: { filePath: 'fakefixturename', encoding: 'encoding' },
headers: {
Accept: 'text/plain',
},
})
.then((resp) => {
expect(resp.status).to.eq(200)
})
})
})

context('qs', () => {
Expand Down

0 comments on commit 5b12c01

Please sign in to comment.