Skip to content

Commit

Permalink
mock.coffee cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshSingla committed Jun 23, 2019
1 parent f1d68a2 commit dcd54ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
14 changes: 2 additions & 12 deletions test/mocha/04-xml-expansion.coffee
Original file line number Diff line number Diff line change
@@ -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()

Expand Down
12 changes: 1 addition & 11 deletions test/mocha/lib/mock.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit dcd54ed

Please sign in to comment.