Get rid of utils/mock

This commit is contained in:
Juan Cruz Viotti 2015-01-08 09:43:50 -03:00
parent 12f46be691
commit f000509995
2 changed files with 9 additions and 35 deletions

View File

@ -1,28 +1,32 @@
_ = require('lodash') _ = require('lodash')
nock = require('nock') nock = require('nock')
sinon = require('sinon') sinon = require('sinon')
mockFs = require('mock-fs')
expect = require('chai').expect expect = require('chai').expect
resin = require('resin-sdk') resin = require('resin-sdk')
permissions = require('./permissions') permissions = require('./permissions')
johnDoeFixture = require('../../tests/fixtures/johndoe') johnDoeFixture = require('../../tests/fixtures/johndoe')
mock = require('../../tests/utils/mock')
describe 'Permissions:', -> describe 'Permissions:', ->
describe '#user()', -> describe '#user()', ->
before -> before ->
mock.connection.init() @isOnlineStub = sinon.stub(resin.connection, 'isOnline')
@isOnlineStub.yields(null, true)
after -> after ->
mock.connection.restore() @isOnlineStub.restore()
beforeEach (done) -> beforeEach (done) ->
mock.fs.init() mockFsOptions = {}
mockFsOptions[resin.settings.get('dataPrefix')] = mockFs.directory()
mockFs(mockFsOptions)
resin.data.prefix.set(resin.settings.get('dataPrefix'), done) resin.data.prefix.set(resin.settings.get('dataPrefix'), done)
afterEach -> afterEach ->
mock.fs.restore() mockFs.restore()
describe 'if not logged in', -> describe 'if not logged in', ->

View File

@ -1,30 +0,0 @@
mockFs = require('mock-fs')
sinon = require('sinon')
resin = require('resin-sdk')
exports.fs =
init: (filesystemConfig = {}) ->
mockFsOptions = {}
# Mock data prefix automatically to remove
# duplication in most of the tests
mockFsOptions[resin.settings.get('dataPrefix')] = mockFs.directory()
for key, value of filesystemConfig
mockFsOptions[value.name] = value.contents
mockFs(mockFsOptions)
restore: ->
mockFs.restore()
isOnlineStub = null
exports.connection =
init: ->
isOnlineStub = sinon.stub(resin.connection, 'isOnline')
isOnlineStub.yields(null, true)
restore: ->
isOnlineStub.restore()