Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "@bes/snap", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Simple snapshot utility used in boilreact", | ||
@@ -15,2 +15,3 @@ "main": "src/index.js", | ||
"devDependencies": { | ||
"history": "^4.6.1", | ||
"node-notifier": "^5.1.2", | ||
@@ -17,0 +18,0 @@ "nodemon": "^1.11.0", |
@@ -28,3 +28,3 @@ 'use strict'; | ||
return ({ numId, body, mess }) => { | ||
return ({ numId, body, mess, history }) => { | ||
@@ -38,2 +38,6 @@ const current = jsonStore[numId]; | ||
jsonStore[numId] = { mess, numId }; | ||
if(history !== undefined) { | ||
const { pathname, search } = history.location; | ||
jsonStore[numId]['href'] = `${pathname}${search}`; | ||
} | ||
fs.writeFileSync(`${outputDir}/${numId}.html`,prettyBody); | ||
@@ -40,0 +44,0 @@ fs.writeJsonSync(outputFile,jsonStore,opts['json']); |
const test = require('tape'); | ||
const fs = require('fs-extra'); | ||
const { createMemoryHistory } = require('history'); | ||
@@ -44,1 +45,25 @@ const snap = require('../src'); | ||
}); | ||
test('Save url/href of history', t => { | ||
const history = createMemoryHistory(); | ||
history.push('/profile?the=query'); | ||
takeSnap({ | ||
numId:'002', | ||
mess:'Hello, History!', | ||
body:'<h1>Hello, History!</h1>', | ||
history:history | ||
}); | ||
const snapJson = fs.readJsonSync(`${DIR_TEST}/snap.json`); | ||
t.deepEqual(snapJson['002'],{ | ||
mess: 'Hello, History!', | ||
numId: '002', | ||
href: '/profile?the=query', | ||
},'snapJson with href updated successfully'); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
57685
146
4