mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-15 09:20:31 +00:00
48 lines
973 B
CoffeeScript
48 lines
973 B
CoffeeScript
expect = require('chai').expect
|
|
mock = require('../../../../tests/utils/mock')
|
|
fsUtils = require('./fs-utils')
|
|
settings = require('../../settings')
|
|
data = require('../../data/data')
|
|
|
|
describe 'FsUtils:', ->
|
|
|
|
describe '#isValidPath()', ->
|
|
|
|
it 'should return false for invalid paths', ->
|
|
|
|
for invalidPath in [
|
|
{ hello: 'world' }
|
|
1234
|
|
[ 1, 2, 3 ]
|
|
undefined
|
|
null
|
|
]
|
|
expect(fsUtils.isValidPath(invalidPath)).to.be.false
|
|
|
|
it 'should return true for valid paths', ->
|
|
|
|
for validPath in [
|
|
settings.get('dataPrefix')
|
|
'/Users/johndoe'
|
|
'../parent'
|
|
'./file/../file2'
|
|
]
|
|
expect(fsUtils.isValidPath(validPath)).to.be.true
|
|
|
|
describe '#isDirectory()', ->
|
|
|
|
FILESYSTEM =
|
|
text:
|
|
name: '/tmp/text'
|
|
contents: 'Hello World'
|
|
directory:
|
|
name: '/tmp/directory'
|
|
contents: {}
|
|
|
|
beforeEach (done) ->
|
|
mock.fs.init(FILESYSTEM)
|
|
data.prefix.set(settings.get('dataPrefix'), done)
|
|
|
|
afterEach ->
|
|
mock.fs.restore()
|