diff --git a/lib/permissions/permissions.spec.coffee b/lib/permissions/permissions.spec.coffee index e6a0c7a1..bffcd3da 100644 --- a/lib/permissions/permissions.spec.coffee +++ b/lib/permissions/permissions.spec.coffee @@ -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', -> diff --git a/tests/utils/mock.coffee b/tests/utils/mock.coffee deleted file mode 100644 index f0690c53..00000000 --- a/tests/utils/mock.coffee +++ /dev/null @@ -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()