Skip to content

Commit

Permalink
fixed bug where it doesn't allow fractional values
Browse files Browse the repository at this point in the history
  • Loading branch information
timrobinson33 committed Apr 14, 2021
1 parent 982e0f5 commit 856aa95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function MainView() {
<input
id="prescribed-dose"
type="number"
step="any"
disabled={showResults}
min={0}
value={prescribedDoseStr}
Expand All @@ -230,6 +231,7 @@ function MainView() {
type="number"
data-testid="stat-dose-strength"
min={0}
step="any"
disabled={showResults || (!numStatDoses)}
value={statDoseStrengthStr}
onChange={event => {
Expand Down
13 changes: 10 additions & 3 deletions src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ test('happy path', () => {
expect(_results()).toBeFalsy()
})


test('select a blank drug -> everything clears', () => {
fillInEverything()
userEvent.selectOptions(_drug(), "0")
Expand Down Expand Up @@ -158,8 +157,12 @@ test('select different strength -> doses reset to blank', () => {
expect(_results()).toBeFalsy()
})

test('prescribed dose invalid values', () => {
test('prescribed dose valid and invalid values', () => {
fillInEverything()
fireChangeEvent(_prescribedDose(), "9.9973")
expect(_prescribedDose()).toHaveValue(9.9973)
fireChangeEvent(_prescribedDose(), "0.0004")
expect(_prescribedDose()).toHaveValue(0.0004)
fireChangeEvent(_prescribedDose(), "999")
expect(_prescribedDose()).toHaveValue(999)
fireChangeEvent(_prescribedDose(), "-7")
Expand All @@ -180,8 +183,12 @@ test('Set stat prn to zero -> clears stat dose', () => {
expect(_statDoseStrength()).toHaveValue(null)
})

test('stat dose strength invalid values', () => {
test('stat dose strength valid and invalid values', () => {
fillInEverything()
fireChangeEvent(_statDoseStrength(), "9.9973")
expect(_statDoseStrength()).toHaveValue(9.9973)
fireChangeEvent(_statDoseStrength(), "0.0004")
expect(_statDoseStrength()).toHaveValue(0.0004)
fireChangeEvent(_statDoseStrength(), "999")
expect(_statDoseStrength()).toHaveValue(999)
fireChangeEvent(_statDoseStrength(), "-7")
Expand Down

0 comments on commit 856aa95

Please sign in to comment.