Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setupNock(filename, functionName, dirName) {
nockBack.fixtures = dirName || __dirname + '/../fixtures'; // causes bugs with ava concurrent run mode
const data = filename.split('/');
const fixtureName = data[data.length - 1].split('.')[0] + '/' + functionName + '.json';
let nockDone = null;
const options = {
// https://github.com/node-nock/nock/issues/484#issuecomment-191822034
after: () => nock.enableNetConnect(/(127.0.0.1|localhost)/),
afterRecord: outputs => outputs.filter(o => !o.scope.match(/(127.0.0.1|localhost)/))
};
const beforeFn = () => {
nockBack.setMode('record');
nockBack(fixtureName, options, callback => nockDone = callback);
};
before(() => {
nockBack.setMode(nockBack.currentMode);
// If we decide to use nock with other modules we should move this to a test helper
nockBack.fixtures = path.join(__dirname, '/nockFixtures');
});
var expect = require('chai').expect;
let kucoin = require('../app/client/kucoin');
var nockBack = require('nock').back;
nockBack.fixtures = './test/fixtures/';
nockBack.setMode('record');
describe('Kucoin init', function() {
it('should initialize properly', function() {
expect(kucoin.exchange).to.equal("Kucoin");
});
});
describe('Kucoin.getTicker()', function() {
it('should get ticker value', function() {
return nockBack('kucoin-ticker.json')
.then(async ({nockDone, context}) => {
const coin = "VEN";
const market = "BTC"
const pair = `${coin}-${market}`;