summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/react-redux/src/components/Header.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/react-redux/src/components/Header.spec.js')
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/react-redux/src/components/Header.spec.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/react-redux/src/components/Header.spec.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/react-redux/src/components/Header.spec.js
new file mode 100644
index 0000000000..6b63df2a34
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/react-redux/src/components/Header.spec.js
@@ -0,0 +1,49 @@
+import React from 'react'
+import TestUtils from 'react-addons-test-utils'
+import Header from './Header'
+import TodoTextInput from './TodoTextInput'
+
+const setup = () => {
+ const props = {
+ addTodo: jest.fn()
+ }
+
+ const renderer = TestUtils.createRenderer()
+ renderer.render(<Header {...props} />)
+ const output = renderer.getRenderOutput()
+
+ return {
+ props: props,
+ output: output,
+ renderer: renderer
+ }
+}
+
+describe('components', () => {
+ describe('Header', () => {
+ it('should render correctly', () => {
+ const { output } = setup()
+
+ expect(output.type).toBe('header')
+ expect(output.props.className).toBe('header')
+
+ const [ h1, input ] = output.props.children
+
+ expect(h1.type).toBe('h1')
+ expect(h1.props.children).toBe('todos')
+
+ expect(input.type).toBe(TodoTextInput)
+ expect(input.props.newTodo).toBe(true)
+ expect(input.props.placeholder).toBe('What needs to be done?')
+ })
+
+ it('should call addTodo if length of text is greater than 0', () => {
+ const { output, props } = setup()
+ const input = output.props.children[1]
+ input.props.onSave('')
+ expect(props.addTodo).not.toBeCalled()
+ input.props.onSave('Use Redux')
+ expect(props.addTodo).toBeCalled()
+ })
+ })
+})