From dcd54ed78242ccffcf3530ec33f987a60e840e4c Mon Sep 17 00:00:00 2001 From: Laksh Singla Date: Sun, 23 Jun 2019 14:37:01 +0530 Subject: [PATCH] mock.coffee cleanup --- test/mocha/04-xml-expansion.coffee | 14 ++------------ test/mocha/lib/mock.coffee | 12 +----------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/test/mocha/04-xml-expansion.coffee b/test/mocha/04-xml-expansion.coffee index a4b66d55..a402fa4e 100644 --- a/test/mocha/04-xml-expansion.coffee +++ b/test/mocha/04-xml-expansion.coffee @@ -1,25 +1,15 @@ Fixture = require './lib/fixture' {eventually, prepare} = require './lib/utils' {unitTests} = require './lib/segregation' -{recordResponses, setupTest} = require './lib/mock' +{recordResponses, setupMock} = require './lib/mock' nock = require 'nock' fs = require 'fs' # To expand the '*' is handled by `imjs` library, therefore unit test (expandStar) unitTests() && describe 'Query', -> - # recordResponses 'dummy.txt', before, after - # before -> - # nock.recorder.rec - # logging: (content) -> fs.appendFile 'record.txt', content, console.error - # output_objects: true - # after -> - # nock.restore() - # nockCallObjects = nock.recorder.play() - # fs.writeFile 'dummy.txt', JSON.stringify(nockCallObjects), console.error - - describe 'expandStar', -> + describe 'expandStar', -> {service} = new Fixture() diff --git a/test/mocha/lib/mock.coffee b/test/mocha/lib/mock.coffee index 94882361..6efcd0ef 100644 --- a/test/mocha/lib/mock.coffee +++ b/test/mocha/lib/mock.coffee @@ -29,9 +29,6 @@ recordResponses = (fileName, before, after) -> parseUrl = (relativeUrl) -> urlObj = url.parse relativeUrl - # pathname = urlObj.pathname?.slice 1 # Remove the leading '/' - # querystring = urlObj.search?.slice 1 # Remove the leading '?' - # fragment = urlObj.hash?.slice 1 # Remove the leading '#' pathname = urlObj.pathname querystring = urlObj.search fragment = urlObj.hash @@ -67,19 +64,12 @@ shouldSetupMock = -> unitTests() setupMock = (url) -> - if not shouldSetupMock + if not shouldSetupMock() return responseFile = findResponse url nock.load responseFile -# nockTest = -> - # nock 'http://localhost:8080/intermine-demo' - # .get '/service/model' - # .replyWithFile 200, path.join __dirname, 'responses/service-model.xml' - - module.exports = - # nockTest: nockTest recordResponses: recordResponses findResponse: findResponse setupMock: setupMock \ No newline at end of file