@erickmerchant/framework
Advanced tools
Comparing version 7.0.0 to 7.1.0
10
main.js
const catchLinks = require('catch-links') | ||
const singlePage = require('single-page') | ||
module.exports = function ({target, store, component, diff}) { | ||
module.exports = function ({target, store, component, diff, raf}) { | ||
raf = raf != null ? raf : window.requestAnimationFrame | ||
let href | ||
@@ -17,2 +19,6 @@ let state = store() | ||
return function (init) { | ||
init({state, dispatch}) | ||
} | ||
function dispatch () { | ||
@@ -28,3 +34,3 @@ state = store(state, ...arguments) | ||
window.requestAnimationFrame(() => { | ||
raf(() => { | ||
rafCalled = false | ||
@@ -31,0 +37,0 @@ |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "A simple data down, actions up framework.", | ||
@@ -26,3 +26,3 @@ "main": "dist/main.js", | ||
"mockery": "^2.0.0", | ||
"nyc": "^8.0.0", | ||
"nyc": "^10.0.0", | ||
"standard": "^8.0.0", | ||
@@ -29,0 +29,0 @@ "tape": "^4.6.0" |
75
test.js
var test = require('tape') | ||
var mockery = require('mockery') | ||
test('', function (t) { | ||
t.plan(1) | ||
test('test main', function (t) { | ||
let singlePage | ||
let theTarget = {} | ||
let dispatchRun = false | ||
let nextRun = false | ||
t.ok(true) | ||
mockery.enable({ | ||
useCleanCache: true, | ||
warnOnReplace: false, | ||
warnOnUnregistered: false | ||
}) | ||
t.plan(12) | ||
mockery.registerMock('single-page', function (callback) { | ||
singlePage = callback | ||
return callback | ||
}) | ||
mockery.registerMock('catch-links', function (target, callback) { | ||
t.equal(target, theTarget) | ||
t.equal(callback, singlePage) | ||
}) | ||
require('./main.js')({ | ||
target: theTarget, | ||
store: function () { | ||
return {} | ||
}, | ||
component: function (href) { | ||
t.equal(href, '/new-href') | ||
return function (app) { | ||
t.deepEqual(Object.keys(app), ['state', 'dispatch', 'show', 'next']) | ||
if (!dispatchRun) { | ||
dispatchRun = true | ||
process.nextTick(function () { | ||
app.dispatch() | ||
app.dispatch() | ||
}, 0) | ||
} | ||
if (!nextRun) { | ||
nextRun = true | ||
app.next(function (target) { | ||
t.deepEqual(target, theTarget) | ||
}) | ||
} | ||
return {} | ||
} | ||
}, | ||
diff: function (target, newTarget) { | ||
t.equal(target, theTarget) | ||
t.deepEqual(newTarget, {}) | ||
}, | ||
raf: function (callback) { | ||
process.nextTick(function () { callback() }) | ||
} | ||
})(function (app) { | ||
t.deepEqual(Object.keys(app), ['state', 'dispatch']) | ||
}) | ||
singlePage('/new-href') | ||
mockery.disable() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4136
94