Add minimal base for tests
This commit is contained in:
parent
72c986fcf2
commit
e29f99735b
12
package.json
12
package.json
|
@ -4,6 +4,8 @@
|
|||
"version": "2.0.0-beta.22",
|
||||
"main": "src/index.js",
|
||||
"module": "src/index.js",
|
||||
"unpkg": "src/index.js",
|
||||
"browser": "src/index.js",
|
||||
"license": "MIT",
|
||||
"repository": "jorgebucaran/hyperapp",
|
||||
"homepage": "https://github.com/jorgebucaran/hyperapp",
|
||||
|
@ -20,7 +22,7 @@
|
|||
"vdom"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "exit 0",
|
||||
"test": "nyc -i esm -r lcov testmatrix test/*.test.js && nyc report",
|
||||
"build": "export dir=${pkg:+lib/$pkg/} pkg=$npm_package_name$pkg; npm run bundle && npm run minify",
|
||||
"bundle": "rollup -i ${dir}$npm_package_module -o ${dir}dist/$pkg.js --no-esModule -mf iife -n $pkg",
|
||||
"minify": "terser ${dir}dist/$pkg.js -o ${dir}dist/$pkg.js -mc --source-map includeSources,url=$pkg.js.map",
|
||||
|
@ -29,7 +31,11 @@
|
|||
"message": "echo ${pkg:+@$npm_package_name/$pkg@}$(node -p \"require('./${pkg:+lib/$pkg/}package').version\")"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rollup": "*",
|
||||
"terser": "^4.0.0"
|
||||
"esm": "^3.2.25",
|
||||
"nyc": "^14.1.1",
|
||||
"testmatrix": "^0.1.2",
|
||||
"jsdom": "15.1.1",
|
||||
"rollup": "^1.16.7",
|
||||
"terser": "^4.1.2"
|
||||
}
|
||||
}
|
||||
|
|
11
src/index.js
11
src/index.js
|
@ -5,7 +5,10 @@ var EMPTY_OBJ = {}
|
|||
var EMPTY_ARR = []
|
||||
var map = EMPTY_ARR.map
|
||||
var isArray = Array.isArray
|
||||
var defer = requestAnimationFrame || setTimeout
|
||||
var defer =
|
||||
typeof requestAnimationFrame === "undefined"
|
||||
? setTimeout
|
||||
: requestAnimationFrame
|
||||
|
||||
var createClass = function(obj) {
|
||||
var out = ""
|
||||
|
@ -373,7 +376,7 @@ var createVNode = function(name, props, children, node, key, type) {
|
|||
}
|
||||
|
||||
var createTextVNode = function(value, node) {
|
||||
return createVNode(value, EMPTY_OBJ, EMPTY_ARR, node, null, TEXT_NODE)
|
||||
return createVNode(value, EMPTY_OBJ, EMPTY_ARR, node, undefined, TEXT_NODE)
|
||||
}
|
||||
|
||||
var recycleNode = function(node) {
|
||||
|
@ -384,7 +387,7 @@ var recycleNode = function(node) {
|
|||
EMPTY_OBJ,
|
||||
map.call(node.childNodes, recycleNode),
|
||||
node,
|
||||
null,
|
||||
undefined,
|
||||
RECYCLED_NODE
|
||||
)
|
||||
}
|
||||
|
@ -416,7 +419,7 @@ export var h = function(name, props) {
|
|||
|
||||
return typeof name === "function"
|
||||
? name(props, children)
|
||||
: createVNode(name, props, children, null, props.key)
|
||||
: createVNode(name, props, children, undefined, props.key)
|
||||
}
|
||||
|
||||
export var app = function(props, enhance) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import { h } from ".."
|
||||
import { deepEqual } from "testmatrix"
|
||||
|
||||
export default {
|
||||
h: [
|
||||
{
|
||||
name: "first test",
|
||||
assert: deepEqual,
|
||||
actual: h("h1", { id: "title" }, "hello"),
|
||||
expected: {
|
||||
name: "h1",
|
||||
props: { id: "title" },
|
||||
children: [
|
||||
{
|
||||
name: "hello",
|
||||
props: {},
|
||||
children: [],
|
||||
node: undefined,
|
||||
type: 3,
|
||||
key: undefined
|
||||
}
|
||||
],
|
||||
node: undefined,
|
||||
type: undefined,
|
||||
key: undefined
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue