Skip to content

Commit

Permalink
test improvements, longterm quick insulin service, react native paper
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-perpignane committed Oct 16, 2023
1 parent 5763967 commit 40e2978
Show file tree
Hide file tree
Showing 23 changed files with 770 additions and 147 deletions.
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug tests",
"skipFiles": [
"<node_internals>/**"
],
"env": {"CI": "true"},
//"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"args": ["--verbose", "-i", "--no-cache", "${workspaceFolder}/src/components/__tests__/DbTextInputComponent.test.tsx"],
"console": "integratedTerminal",
"program": "${workspaceRoot}/node_modules/.bin/jest",
// "outFiles": [
// "${workspaceFolder}/**/*.js"
// ]
}
]
}
184 changes: 181 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
"lint": "eslint .",
"lint-fix": "eslint --fix .",
"start": "react-native start",
"test": "jest --coverage"
"test": "jest --coverage --verbose"
},
"dependencies": {
"@react-navigation/native": "^6.1.8",
"@react-navigation/native-stack": "^6.9.14",
"@types/jest": "^29.5.5",
"react": "18.2.0",
"react-native": "0.72.5",
"react-native-paper": "^5.10.6",
"react-native-safe-area-context": "^4.7.2",
"react-native-screens": "^3.25.0"
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/DbButtonComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import {Pressable, PressableProps, StyleSheet, Text} from 'react-native'
import {Pressable, PressableProps, StyleSheet} from 'react-native'
import {Text} from 'react-native-paper'

interface DbButtonProps extends PressableProps {
title: string
Expand All @@ -9,14 +10,13 @@ interface DbButtonProps extends PressableProps {
export function DbButton(props: DbButtonProps): JSX.Element {
return (
<Pressable
onPress={props.onPress}
style={({pressed}) => [
{
backgroundColor: pressed ? 'darkturquoise' : 'blue',
},
styles.dbButton,
]}
testID={props.testID}>
{...props}>
<Text style={styles.dbButtonText}>{props.title}</Text>
</Pressable>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/DbNumericTextInputComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {TextInputProps} from 'react-native'
import {TextInputProps} from 'react-native-paper'
import {DbTextInput} from './DbTextInputComponent'

export function DbNumericTextInput(props: TextInputProps): JSX.Element {
Expand Down
3 changes: 2 additions & 1 deletion src/components/DbTextInputComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import {StyleSheet, TextInput, TextInputProps} from 'react-native'
import {TextInput, TextInputProps} from 'react-native-paper'
import {StyleSheet} from 'react-native'

export function DbTextInput(props: TextInputProps): JSX.Element {
let localProps
Expand Down
25 changes: 24 additions & 1 deletion src/components/__tests__/DbButtonComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,33 @@ import {it, expect} from '@jest/globals'
import {fireEvent, render, screen} from '@testing-library/react-native'

it('renders correctly', async () => {
const Sample = () => <DbButton title="coucou" testID="coucou" />
let i = 0

const Sample = () => (
<DbButton title="coucou" testID="coucou" onPress={() => i++} />
)

render(<Sample />)

let punctualButton = screen.getByTestId('coucou')
expect(punctualButton).toBeDefined()

fireEvent(punctualButton, 'onPress')
expect(i).toEqual(1)
})

it('renders correctly when pressed', async () => {
let i = 0

const Sample = () => (
<DbButton title="coucou" testID="coucou" testOnly_pressed={true} onPress={() => i++} />
)

render(<Sample />)

let punctualButton = screen.getByTestId('coucou')
expect(punctualButton).toBeDefined()

fireEvent(punctualButton, 'onPress')
expect(i).toEqual(1)
})
Loading

0 comments on commit 40e2978

Please sign in to comment.