Skip to content

Commit 26d2a67

Browse files
committed
Update test harness and reorganize tests a bit.
1 parent a1a6981 commit 26d2a67

File tree

2 files changed

+52
-34
lines changed

2 files changed

+52
-34
lines changed

package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,29 @@
2828
},
2929
"jest": {
3030
"testURL": "http://localhost",
31+
"testMatch": [
32+
"**/__tests__/**/*.?(m)js?(x)",
33+
"**/?(*.)(spec|test).?(m)js?(x)"
34+
],
35+
"transform": {
36+
"\\.mjs$": "babel-jest"
37+
},
38+
"moduleFileExtensions": [
39+
"mjs",
40+
"js"
41+
],
3142
"moduleNameMapper": {
3243
"^htm-babel-plugin$": "<rootDir>/packages/babel-plugin-htm/dist/babel-plugin-htm.js",
3344
"^babel-plugin-htm$": "<rootDir>/packages/babel-plugin-htm/dist/babel-plugin-htm.js",
3445
"^htm$": "<rootDir>/dist/htm.js",
3546
"^htm/preact$": "<rootDir>/preact/index.js"
3647
}
3748
},
49+
"babel": {
50+
"presets": [
51+
"env"
52+
]
53+
},
3854
"repository": "developit/htm",
3955
"keywords": [
4056
"Hyperscript Tagged Markup",
@@ -50,7 +66,9 @@
5066
"license": "Apache-2.0",
5167
"homepage": "https://github.com/developit/htm",
5268
"devDependencies": {
53-
"@babel/core": "^7.1.2",
69+
"@babel/preset-env": "^7.1.6",
70+
"babel-jest": "^23.6.0",
71+
"babel-preset-env": "^1.7.0",
5472
"eslint": "^5.2.0",
5573
"eslint-config-developit": "^1.1.1",
5674
"jest": "^23.4.2",

test/preact.test.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
const { html, Component, render } = require('htm/preact');
1515

16-
describe('preact-html', () => {
16+
describe('htm/preact', () => {
1717
const scratch = document.createElement('div');
1818
document.body.appendChild(scratch);
1919

@@ -100,36 +100,36 @@ describe('preact-html', () => {
100100
scratch.innerHTML = '';
101101

102102
});
103-
});
104103

105-
describe('performance', () => {
106-
test('creation', () => {
107-
const results = [];
108-
const Foo = ({ name }) => html`<div class="foo">${name}</div>`;
109-
const statics = [
110-
'\n<div id=app data-loading="true">\n\t<h1>Hello World</h1>\n\t<ul class="items" id=', '>\n\t',
111-
'\n\t</ul>\n\t\n\t<', ' name="foo" />\n\t<', ' name="other">content</', '>\n\n</div>'
112-
];
113-
let count = 0;
114-
function go(count) {
115-
return html(
116-
statics.concat(['count:', count]),
117-
`id${count}`,
118-
html(['<li data-id="','">', '</li>'], 'i'+count, 'some text #'+count),
119-
Foo, Foo, Foo
120-
);
121-
}
122-
let now = performance.now();
123-
const start = now;
124-
while ((now = performance.now()) < start+2000) {
125-
count++;
126-
if (results.push(String(go(count)))===10) results.length = 0;
127-
}
128-
const elapsed = now - start;
129-
const hz = count / elapsed * 1000;
130-
// eslint-disable-next-line no-console
131-
console.log(`Creation: ${hz|0}/s, average: ${elapsed/count.toFixed(4)}ms`);
132-
expect(elapsed).toBeGreaterThan(999);
133-
expect(hz).toBeGreaterThan(10);
134-
});
135-
});
104+
// describe('performance', () => {
105+
// test('creation', () => {
106+
// const results = [];
107+
// const Foo = ({ name }) => html`<div class="foo">${name}</div>`;
108+
// const statics = [
109+
// '\n<div id=app data-loading="true">\n\t<h1>Hello World</h1>\n\t<ul class="items" id=', '>\n\t',
110+
// '\n\t</ul>\n\t\n\t<', ' name="foo" />\n\t<', ' name="other">content</', '>\n\n</div>'
111+
// ];
112+
// let count = 0;
113+
// function go(count) {
114+
// return html(
115+
// statics.concat(['count:', count]),
116+
// `id${count}`,
117+
// html(['<li data-id="','">', '</li>'], 'i'+count, 'some text #'+count),
118+
// Foo, Foo, Foo
119+
// );
120+
// }
121+
// let now = performance.now();
122+
// const start = now;
123+
// while ((now = performance.now()) < start+2000) {
124+
// count++;
125+
// if (results.push(String(go(count)))===10) results.length = 0;
126+
// }
127+
// const elapsed = now - start;
128+
// const hz = count / elapsed * 1000;
129+
// // eslint-disable-next-line no-console
130+
// console.log(`Creation: ${hz|0}/s, average: ${elapsed/count.toFixed(4)}ms`);
131+
// expect(elapsed).toBeGreaterThan(999);
132+
// expect(hz).toBeGreaterThan(10);
133+
// });
134+
// });
135+
});

0 commit comments

Comments
 (0)