Skip to content

Commit

Permalink
Add tests for deprecated data option
Browse files Browse the repository at this point in the history
  • Loading branch information
flintinatux committed Apr 12, 2019
1 parent 8787e88 commit f7a100b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- '10'
- '8'
- '7'
- '6'
before_install:
- npm install -g yarn@1.10.0
Expand Down
2 changes: 1 addition & 1 deletion lib/gimme.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const gimme = opts => {
json = true
} = opts

if (data) console.log(`[${name}] The 'data' option is deprecated in favor of 'body'.`)
if (data) console.warn(`[${name}] The 'data' option is deprecated in favor of 'body'.`)

const {
body = data,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"raw-body": "^2.2.0"
},
"devDependencies": {
"@articulate/spy": "^0.0.1",
"chai": "^4.1.1",
"coveralls": "^2.13.1",
"eslint": "^4.3.0",
Expand Down
2 changes: 2 additions & 0 deletions test/00-setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const nock = require('nock')
const qs = require('qs')
const spy = require('@articulate/spy')
const URL = require('url')

const { curry, compose, prop } = require('ramda')
Expand Down Expand Up @@ -28,6 +29,7 @@ const respond = curry(function(method, uri, body) {
return [ 200, resBody, headers ]
})

console.warn = spy()
nock.disableNetConnect()

beforeEach(() => {
Expand Down
26 changes: 26 additions & 0 deletions test/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { expect } = require('chai')
const property = require('prop-factory')

const gimme = require('..')
const { url } = require('./00-setup')

describe('data', () => {
const body = { baz: 'bop' }
const res = property()

beforeEach(() => {
res(undefined)
})

beforeEach(() =>
gimme({ data: body, method: 'POST', url }).then(res)
)

it('is used for non-GET request body', () =>
expect(res().body.body).to.eql(body)
)

it('is deprecated', () =>
expect(console.warn.calls[0][0]).to.include('deprecated')
)
})
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
joi "^10.6.0"
ramda "^0.24.1"

"@articulate/spy@^0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@articulate/spy/-/spy-0.0.1.tgz#2da9fdb919075fa5fc3868017e17b43b8528a399"
integrity sha512-Ewt95Ba4Kg/n28OMqm/bfUOeq7vURjYL1EXmPOVzqMPPG1tBGPcEftQzlcIb+cz9rNh/5d7uxdPo9eqD8x5hXg==

acorn-jsx@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"
Expand Down

0 comments on commit f7a100b

Please sign in to comment.