Skip to content

Commit 6461999

Browse files
committed
fix tests
1 parent 375c441 commit 6461999

File tree

5 files changed

+20
-75
lines changed

5 files changed

+20
-75
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"copy-typescript-definition": "copyfiles -f src/*.d.ts dist",
3434
"test": "eslint src test && tsc && npm run test:mocha && npm run test:mocha:compat && npm run test:mocha:debug && npm run bench",
3535
"test:mocha": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/*.test.js",
36-
"test:mocha:compat": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/compat.test.js 'test/compat/index.test.js'",
37-
"test:mocha:debug": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/debug.test.js 'test/debug/index.test.js'",
36+
"test:mocha:compat": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js 'test/compat/index.test.js'",
37+
"test:mocha:debug": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js 'test/debug/index.test.js'",
3838
"format": "prettier src/**/*.{d.ts,js} test/**/*.js --write",
3939
"prepublishOnly": "npm run build",
4040
"release": "npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"

test/debug.test.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/debug/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'preact/debug';
2-
import { render } from '../../src';
2+
import render from '../../src';
33
import { h } from 'preact';
44
import { expect } from 'chai';
55

test/pretty.test.js

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render as basicRender } from '../src';
1+
import basicRender from '../src';
22
import { render } from '../src/jsx';
33
import { h, Fragment } from 'preact';
44
import { expect } from 'chai';
@@ -120,35 +120,19 @@ describe('pretty', () => {
120120
// prettier-ignore
121121
expect(prettyRender(
122122
<div>hello{' '} <b /></div>
123-
)).to.equal(dedent`
124-
<div>
125-
hello
126-
<b></b>
127-
</div>
128-
`);
123+
)).to.equal(`<div>\n\thello \n\t<b></b>\n</div>`);
129124

130125
// prettier-ignore
131126
expect(prettyRender(
132127
<div>hello{' '} <b />{'a'}{'b'}</div>
133-
)).to.equal(dedent`
134-
<div>
135-
hello
136-
<b></b>
137-
ab
138-
</div>
139-
`);
128+
)).to.equal(`<div>\n\thello \n\t<b></b>\n\tab\n</div>`);
140129
});
141130

142131
it('should join adjacent text nodeswith Fragments', () => {
143132
// prettier-ignore
144133
expect(prettyRender(
145134
<div><Fragment>foo</Fragment>bar{' '} <b /></div>
146-
)).to.equal(dedent`
147-
<div>
148-
foobar
149-
<b></b>
150-
</div>
151-
`);
135+
)).to.equal(`<div>\n\tfoobar \n\t<b></b>\n</div>`);
152136
});
153137

154138
it('should collapse whitespace', () => {
@@ -158,25 +142,15 @@ describe('pretty', () => {
158142
a<a>b</a>
159143
</p>
160144
)
161-
).to.equal(dedent`
162-
<p>
163-
a
164-
<a>b</a>
165-
</p>
166-
`);
145+
).to.equal(`<p>\n\ta\n\t<a>b</a>\n</p>`);
167146

168147
expect(
169148
prettyRender(
170149
<p>
171150
a <a>b</a>
172151
</p>
173152
)
174-
).to.equal(dedent`
175-
<p>
176-
a
177-
<a>b</a>
178-
</p>
179-
`);
153+
).to.equal(`<p>\n\ta \n\t<a>b</a>\n</p>`);
180154

181155
expect(
182156
prettyRender(
@@ -198,12 +172,7 @@ describe('pretty', () => {
198172
a <a>b</a>
199173
</p>
200174
)
201-
).to.equal(dedent`
202-
<p>
203-
a\
204-
<a>b</a>
205-
</p>
206-
`);
175+
).to.equal(`<p>\n\ta \n\t<a>b</a>\n</p>`);
207176

208177
expect(prettyRender(<a> b </a>)).to.equal(dedent`
209178
<a> b </a>
@@ -215,12 +184,7 @@ describe('pretty', () => {
215184
<b /> a{' '}
216185
</p>
217186
)
218-
).to.equal(dedent`
219-
<p>
220-
<b></b>
221-
\ a\
222-
</p>
223-
`);
187+
).to.equal(`<p>\n\t<b></b>\n\t a \n</p>`);
224188
});
225189

226190
it('should prevent JSON injection', () => {

test/render.test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import render from '../src';
22
import renderToStringPretty from '../src/pretty';
33
import renderToStringJSX from '../src/jsx';
4-
import { h, Component, createContext, Fragment, options } from 'preact';
4+
import {
5+
h,
6+
Component,
7+
createContext,
8+
Fragment,
9+
options,
10+
createRef
11+
} from 'preact';
512
import {
613
useState,
714
useContext,
@@ -80,7 +87,7 @@ describe('render', () => {
8087
});
8188

8289
it('should omit ref attribute', () => {
83-
let rendered = render(<div ref="test" />),
90+
let rendered = render(<div ref={createRef()} />),
8491
expected = `<div></div>`;
8592

8693
expect(rendered).to.equal(expected);

0 commit comments

Comments
 (0)