Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a9c5b0

Browse files
committed
Cleans up testing
1 parent84ff69b commit4a9c5b0

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

‎package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"private":true,
55
"description":"",
66
"main":"index.js",
7+
"engines": {
8+
"node":">=7.0.0"
9+
},
710
"scripts": {
811
"setup":"typings install",
912
"build":"npm run setup && npm run test && webpack",
@@ -36,7 +39,7 @@
3639
"ts-jest":"^17.0.3",
3740
"ts-loader":"^0.8.2",
3841
"tslint":"^3.14.0",
39-
"typescript":"2.0.3",
42+
"typescript":"2.0.6",
4043
"typings":"1.3.2",
4144
"webpack":"^1.13.1",
4245
"webpack-fail-plugin":"^1.0.5",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
exports[`components/Counter renders 1`]=`
2+
<CounterComponent
3+
counter={
4+
Object {
5+
"value":0,
6+
}
7+
}
8+
error=""
9+
increment={[Function]}
10+
isLoading={false}
11+
isSaving={false}
12+
label="a counter!"
13+
load={[Function]}
14+
save={[Function]}
15+
store={
16+
Object {
17+
"dispatch": [Function],
18+
"getState": [Function],
19+
"replaceReducer": [Function],
20+
"subscribe": [Function],
21+
Symbol(observable): [Function],
22+
}
23+
} />
24+
`;

‎src/components/__tests__/counter_spec.tsx‎

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,31 @@
1+
// tslint:disable-next-line no-unused-variable
12
import*asReactfrom'react'
23
import*asTestUtilsfrom'react-addons-test-utils'
34

45
import{createStore}from'redux'
5-
import{Provider}from'react-redux'
66

77
import{Counter}from'../counter'
88
import{reducers}from'../../reducers'
99

1010
describe('components/Counter',()=>{
1111

12-
functionrenderElement(el:React.ReactElement<{}>){
13-
returnTestUtils.renderIntoDocument(el)asReact.Component<{},{}>
14-
}
15-
16-
functionfindComponentByType(root:React.Component<{},{}>,type:any):React.Component<{},{}>{
17-
returnTestUtils.findRenderedComponentWithType(root,type)
18-
}
19-
20-
functionsetup():React.Component<{},{}>{
12+
it('renders',()=>{
2113
conststore=createStore(reducers)
22-
constwrapper=renderElement(
23-
<Providerstore={store}>
24-
<Counterlabel='a counter!'/>
25-
</Provider>
26-
)
27-
constcounter=findComponentByType(wrapper,Counter)
28-
returncounter
29-
}
30-
31-
it('starts at 0',()=>{
32-
constcounter=setup()
33-
constpre=TestUtils.findRenderedDOMComponentWithTag(counter,'pre')
34-
expect(JSON.parse(pre.textContent).counter.value).toEqual(0)
35-
})
36-
37-
it('shows a label',()=>{
38-
constcounter=setup()
39-
constlabel=TestUtils.findRenderedDOMComponentWithTag(counter,'legend')
40-
expect(label.textContent).toEqual('a counter!')
14+
constrenderer=TestUtils.createRenderer()
15+
expect(renderer.render(
16+
<Counterlabel='a counter!'store={store}/>
17+
)).toMatchSnapshot()
4118
})
4219

4320
describe('clicking "increment"',()=>{
4421
it('increments counter',()=>{
45-
constcounter=setup()
46-
const[increment]=TestUtils.scryRenderedDOMComponentsWithTag(counter,'button')
22+
conststore=createStore(reducers)
23+
constcounter=TestUtils.renderIntoDocument(
24+
<Counterlabel='a counter!'store={store}/>
25+
)
26+
const[
27+
increment,
28+
]=TestUtils.scryRenderedDOMComponentsWithTag(counter,'button')
4729
TestUtils.Simulate.click(increment)
4830
TestUtils.Simulate.click(increment)
4931
TestUtils.Simulate.click(increment)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp