mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 02:39:49 +00:00
Get rid of utils/mock
This commit is contained in:
parent
12f46be691
commit
f000509995
@ -1,28 +1,32 @@
|
||||
_ = require('lodash')
|
||||
nock = require('nock')
|
||||
sinon = require('sinon')
|
||||
mockFs = require('mock-fs')
|
||||
expect = require('chai').expect
|
||||
resin = require('resin-sdk')
|
||||
permissions = require('./permissions')
|
||||
johnDoeFixture = require('../../tests/fixtures/johndoe')
|
||||
mock = require('../../tests/utils/mock')
|
||||
|
||||
describe 'Permissions:', ->
|
||||
|
||||
describe '#user()', ->
|
||||
|
||||
before ->
|
||||
mock.connection.init()
|
||||
@isOnlineStub = sinon.stub(resin.connection, 'isOnline')
|
||||
@isOnlineStub.yields(null, true)
|
||||
|
||||
after ->
|
||||
mock.connection.restore()
|
||||
@isOnlineStub.restore()
|
||||
|
||||
beforeEach (done) ->
|
||||
mock.fs.init()
|
||||
mockFsOptions = {}
|
||||
mockFsOptions[resin.settings.get('dataPrefix')] = mockFs.directory()
|
||||
mockFs(mockFsOptions)
|
||||
|
||||
resin.data.prefix.set(resin.settings.get('dataPrefix'), done)
|
||||
|
||||
afterEach ->
|
||||
mock.fs.restore()
|
||||
mockFs.restore()
|
||||
|
||||
describe 'if not logged in', ->
|
||||
|
||||
|
@ -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()
|
Loading…
Reference in New Issue
Block a user