Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better emulate jQuery by resolving successful request on JSON parse error #46

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
16 changes: 7 additions & 9 deletions test/test-najax.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/* globals describe beforeEach it */
/* globals describe beforeEach afterEach it */
var najax = require('../lib/najax.js')
var expect = require('chai').expect
var nock = require('nock')
var zlib = require('zlib')

// prevent cross-test or cross-describe contamination by
// globally clearing nock after each test
afterEach(function () {
nock.cleanAll()
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I elected to do this globally since we were dealing with contamination between describe blocks.

describe('method overloads', function (next) {
najax.defaults({ error: error })

Expand Down Expand Up @@ -73,14 +79,6 @@ describe('url', function (next) {
}

it('should accept plain URL', function (done) {
// An extra nock seems to be being
// registered and affecting the subsequent tests
// (I beleive it is caused by:
// https://github.com/najaxjs/najax/commit/54cfac6aa0b7cf8a89efae0f39d1f054c8859de0
// commenting out the 'default to "GET"' test also fixes this)
// make an extra call to najax in order to clear it
najax({url: 'http://www.example.com'})

mockPlain('get')
najax('http://www.example.com', createSuccess(done))
})
Expand Down