mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-29 15:44:26 +00:00
Get rid of utils/mock
This commit is contained in:
parent
12f46be691
commit
f000509995
@ -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', ->
|
||||||
|
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user