mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Created basic tests
This commit is contained in:
15
__tests__/components/Menu/Header.js
Normal file
15
__tests__/components/Menu/Header.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from 'react'
|
||||
import { cleanup, render } from '@testing-library/react-native/pure'
|
||||
|
||||
import MenuHeader from '@components/Menu/Header'
|
||||
|
||||
describe('Testing component menu header', () => {
|
||||
afterEach(cleanup)
|
||||
|
||||
it('with text only', () => {
|
||||
const { getByText, toJSON } = render(<MenuHeader heading='test' />)
|
||||
|
||||
getByText('test')
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
})
|
50
__tests__/components/Menu/Row.js
Normal file
50
__tests__/components/Menu/Row.js
Normal file
@ -0,0 +1,50 @@
|
||||
import React from 'react'
|
||||
import { toBeDisabled } from '@testing-library/jest-native'
|
||||
import { cleanup, fireEvent, render } from '@testing-library/react-native'
|
||||
|
||||
import MenuRow from '@components/Menu/Row'
|
||||
|
||||
expect.extend({ toBeDisabled })
|
||||
|
||||
describe('Testing component menu row', () => {
|
||||
afterEach(cleanup)
|
||||
|
||||
it('with title only', () => {
|
||||
const { getByText, toJSON } = render(<MenuRow title='test title' />)
|
||||
getByText('test title')
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('with title and content', () => {
|
||||
const { getByText, toJSON } = render(
|
||||
<MenuRow title='test title' content='test content' />
|
||||
)
|
||||
getByText('test title')
|
||||
getByText('test content')
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('on press event', () => {
|
||||
const onPress = jest.fn()
|
||||
const { getByTestId, toJSON } = render(
|
||||
<MenuRow title='test' onPress={onPress} />
|
||||
)
|
||||
fireEvent.press(getByTestId('base'))
|
||||
|
||||
expect(onPress).toHaveBeenCalled()
|
||||
expect(onPress).toHaveBeenCalledTimes(1)
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('loading state', () => {
|
||||
const onPress = jest.fn()
|
||||
const { getByTestId, toJSON } = render(
|
||||
<MenuRow title='test' loading onPress={onPress} />
|
||||
)
|
||||
fireEvent.press(getByTestId('base'))
|
||||
|
||||
expect(onPress).toHaveBeenCalledTimes(0)
|
||||
expect(getByTestId('base')).toBeDisabled()
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
})
|
29
__tests__/components/Menu/__snapshots__/Header.js.snap
Normal file
29
__tests__/components/Menu/__snapshots__/Header.js.snap
Normal file
@ -0,0 +1,29 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Testing component menu header with text only 1`] = `
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"paddingBottom": 8,
|
||||
"paddingLeft": 16,
|
||||
"paddingRight": 16,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"fontSize": 14,
|
||||
"fontWeight": "600",
|
||||
},
|
||||
Object {
|
||||
"color": "rgb(135, 135, 135)",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
test
|
||||
</Text>
|
||||
</View>
|
||||
`;
|
273
__tests__/components/Menu/__snapshots__/Row.js.snap
Normal file
273
__tests__/components/Menu/__snapshots__/Row.js.snap
Normal file
@ -0,0 +1,273 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Testing component menu row loading state 1`] = `
|
||||
<View
|
||||
accessible={true}
|
||||
focusable={true}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onResponderGrant={[Function]}
|
||||
onResponderMove={[Function]}
|
||||
onResponderRelease={[Function]}
|
||||
onResponderTerminate={[Function]}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"height": 50,
|
||||
}
|
||||
}
|
||||
testID="base"
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"paddingLeft": 16,
|
||||
"paddingRight": 16,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexBasis": "70%",
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"fontSize": 16,
|
||||
},
|
||||
Object {
|
||||
"color": "rgb(18, 18, 18)",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
test
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`Testing component menu row on press event 1`] = `
|
||||
<View
|
||||
accessible={true}
|
||||
focusable={true}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onResponderGrant={[Function]}
|
||||
onResponderMove={[Function]}
|
||||
onResponderRelease={[Function]}
|
||||
onResponderTerminate={[Function]}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"height": 50,
|
||||
}
|
||||
}
|
||||
testID="base"
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"paddingLeft": 16,
|
||||
"paddingRight": 16,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexBasis": "70%",
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"fontSize": 16,
|
||||
},
|
||||
Object {
|
||||
"color": "rgb(18, 18, 18)",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
test
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`Testing component menu row with title and content 1`] = `
|
||||
<View
|
||||
accessible={true}
|
||||
focusable={true}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onResponderGrant={[Function]}
|
||||
onResponderMove={[Function]}
|
||||
onResponderRelease={[Function]}
|
||||
onResponderTerminate={[Function]}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"height": 50,
|
||||
}
|
||||
}
|
||||
testID="base"
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"paddingLeft": 16,
|
||||
"paddingRight": 16,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexBasis": "70%",
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"fontSize": 16,
|
||||
},
|
||||
Object {
|
||||
"color": "rgb(18, 18, 18)",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
test title
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexBasis": "30%",
|
||||
"flexDirection": "row",
|
||||
"justifyContent": "flex-end",
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"fontSize": 16,
|
||||
},
|
||||
Object {
|
||||
"color": "rgb(135, 135, 135)",
|
||||
"opacity": 1,
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
test content
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`Testing component menu row with title only 1`] = `
|
||||
<View
|
||||
accessible={true}
|
||||
focusable={true}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onResponderGrant={[Function]}
|
||||
onResponderMove={[Function]}
|
||||
onResponderRelease={[Function]}
|
||||
onResponderTerminate={[Function]}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"height": 50,
|
||||
}
|
||||
}
|
||||
testID="base"
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
"paddingLeft": 16,
|
||||
"paddingRight": 16,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexBasis": "70%",
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"fontSize": 16,
|
||||
},
|
||||
Object {
|
||||
"color": "rgb(18, 18, 18)",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
test title
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
Reference in New Issue
Block a user