Merge branch 'chore/extend-license-test' into 'main'
Chore/extend license test See merge request bloodyhealth/drip!539
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import React from 'react'
|
||||
import { render, screen, fireEvent } from '@testing-library/react-native'
|
||||
import AcceptLicense from '../components/AcceptLicense'
|
||||
|
||||
import { saveLicenseFlag } from '../local-storage'
|
||||
|
||||
jest.mock('../local-storage', () => ({
|
||||
saveLicenseFlag: jest.fn(() => Promise.resolve()),
|
||||
}))
|
||||
|
||||
jest.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (str, options) => {
|
||||
return str + (options ? JSON.stringify(options) : '')
|
||||
},
|
||||
}),
|
||||
}))
|
||||
|
||||
describe('AcceptLicense', () => {
|
||||
test('On clicking OK button, the license is accepted', async () => {
|
||||
const mockedSetLicense = jest.fn()
|
||||
render(<AcceptLicense setLicense={mockedSetLicense} />)
|
||||
|
||||
const okButton = screen.getByText('ok', { exact: false })
|
||||
|
||||
fireEvent(okButton, 'click')
|
||||
|
||||
await expect(saveLicenseFlag).toHaveBeenCalled()
|
||||
expect(mockedSetLicense).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('There is a Cancel button', async () => {
|
||||
render(<AcceptLicense setLicense={jest.fn()} />)
|
||||
|
||||
screen.getByText('cancel', { exact: false })
|
||||
})
|
||||
})
|
||||
@@ -12,8 +12,15 @@ jest.mock('react-i18next', () => ({
|
||||
|
||||
describe('License screen', () => {
|
||||
test('It should have a correct year', async () => {
|
||||
render(<License setLicense={() => {}} />)
|
||||
render(<License />)
|
||||
const year = new Date().getFullYear().toString()
|
||||
|
||||
screen.getByText(year, { exact: false })
|
||||
})
|
||||
|
||||
test('It should match the snapshot', async () => {
|
||||
const licenseScreen = render(<License />)
|
||||
|
||||
expect(licenseScreen).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`License screen It should match the snapshot 1`] = `
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "#E9F2ED",
|
||||
"flex": 1,
|
||||
}
|
||||
}
|
||||
>
|
||||
<RCTScrollView
|
||||
contentContainerStyle={
|
||||
Array [
|
||||
Object {
|
||||
"backgroundColor": "#E9F2ED",
|
||||
"flexGrow": 1,
|
||||
},
|
||||
undefined,
|
||||
]
|
||||
}
|
||||
>
|
||||
<View>
|
||||
<Text
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"color": "#555",
|
||||
"fontFamily": "Jost-Book",
|
||||
"fontSize": 34.285714285714285,
|
||||
},
|
||||
Object {
|
||||
"alignSelf": "center",
|
||||
"color": "#3A2671",
|
||||
"fontFamily": "Jost-Bold",
|
||||
"fontSize": 51.42857142857143,
|
||||
"fontWeight": "700",
|
||||
"marginHorizontal": 34.285714285714285,
|
||||
"marginVertical": 42.857142857142854,
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
title
|
||||
</Text>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"marginBottom": 34.285714285714285,
|
||||
"marginHorizontal": 34.285714285714285,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"color": "#555",
|
||||
"fontFamily": "Jost-Book",
|
||||
"fontSize": 34.285714285714285,
|
||||
},
|
||||
undefined,
|
||||
]
|
||||
}
|
||||
>
|
||||
text{"currentYear":2022}
|
||||
</Text>
|
||||
<Text
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"color": "#3A2671",
|
||||
"fontFamily": "Jost-Book",
|
||||
"fontSize": 34.285714285714285,
|
||||
"textDecorationLine": "underline",
|
||||
}
|
||||
}
|
||||
>
|
||||
https://www.gnu.org/licenses/gpl-3.0.html
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</RCTScrollView>
|
||||
</View>
|
||||
`;
|
||||
Reference in New Issue
Block a user