Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workshopper-adventure-storage

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workshopper-adventure-storage - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "workshopper-adventure-storage",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,14 +7,20 @@ var storage = require('..')

var fileName = './foo/bar/index.json'
var testStorage
var invalidJson = './foo/bar/invalid.json'
var testStorage = storage('foo', 'bar')
/**
* Initialize storage and save a file.
*/
before(function (done) {
testStorage = storage('foo', 'bar')
testStorage.save('index', {
foo: 'bar'
}, function (err) {
beforeEach(function (done) {
function writeBadJson (err) {
if (err) return done(err)
done()
fs.writeFile(invalidJson, '{', done)
}
testStorage.reset(function (err) {
if (err) return done(err)
testStorage.save('index', {
foo: 'bar'
}, writeBadJson)
})

@@ -28,29 +34,47 @@ })

it('should save serialized storage to the data directory', function (done) {
fs.readFile(fileName, function (err, data) {
if (err) return done(err)
var fileData
try {
fileData = JSON.parse(data)
} catch (e) {
done(e)
}
done(null, fileData)
describe('#save', function() {
it('should save serialized storage to the data directory', function (done) {
fs.readFile(fileName, function (err, data) {
if (err) return done(err)
var fileData
try {
fileData = JSON.parse(data)
} catch (e) {
done(e)
}
done()
})
})
})
it('should retrive a stored file', function (done) {
testStorage.get('index', function (err, file) {
if (err) return done(err)
expect(file.foo).to.equal('bar')
done()
describe('#get', function () {
it('should retrive a stored file', function (done) {
testStorage.get('index', function (err, file) {
if (err) return done(err)
expect(file.foo).to.equal('bar')
done()
})
})
it('handle invalid JSON', function (done) {
fs.readFile(invalidJson, function (err, data) {
if (err) return done(err)
var fileData
try {
fileData = JSON.parse(data)
} catch (e) {
return done()
}
done('read the file!')
})
})
})
it('should clean the storage directory', function (done) {
testStorage.reset(function () {
fs.stat('./foo/bar', function (err, stats) {
if (err && err.code === 'ENOENT') return done()
done('file still exists!')
describe('#reset', function () {
it('should clean the storage directory', function (done) {
testStorage.reset(function () {
fs.stat('./foo/bar', function (err, stats) {
if (err && err.code === 'ENOENT') return done()
done('file still exists!')
})
})

@@ -57,0 +81,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc