Skip to content

Commit

Permalink
fix: allow grace period minutes only (#1064)
Browse files Browse the repository at this point in the history
* fix: allow grace period minutes only

* fix: zero minutes error
  • Loading branch information
KristinAoki authored May 31, 2024
1 parent a340320 commit 9b4eb10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/grading-settings/deadline-section/DeadlineSection.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ describe('<DeadlineSection />', () => {
expect(testObj.gracePeriod.minutes).toBe(13);
});
});
it('checking deadline input value if grace Period has no hours', async () => {
const { getByTestId } = render(<RootWrapper
gracePeriod={{ hours: 0, minutes: 13 }}
setGradingData={setGradingData}
/>);
await waitFor(() => {
const inputElement = getByTestId('deadline-period-input');
expect(inputElement.value).toBe('00:13');
});
});
it('checking deadline input value if grace Period has no minutes', async () => {
const { getByTestId } = render(<RootWrapper
gracePeriod={{ hours: 13, minutes: 0 }}
setGradingData={setGradingData}
/>);
await waitFor(() => {
const inputElement = getByTestId('deadline-period-input');
expect(inputElement.value).toBe('13:00');
});
});
it('checking deadline input value if grace Period equal null', async () => {
const { getByTestId } = render(<RootWrapper gracePeriod={null} setGradingData={setGradingData} />);
await waitFor(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/grading-settings/deadline-section/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DeadlineSection = ({
intl, setShowSavePrompt, gracePeriod, setGradingData, setShowSuccessAlert,
}) => {
const timeStampValue = gracePeriod
? gracePeriod.hours && `${formatTime(gracePeriod.hours)}:${formatTime(gracePeriod.minutes)}`
? `${formatTime(gracePeriod.hours)}:${formatTime(gracePeriod.minutes)}`
: DEFAULT_TIME_STAMP;
const [newDeadlineValue, setNewDeadlineValue] = useState(timeStampValue);
const [isError, setIsError] = useState(false);
Expand Down

0 comments on commit 9b4eb10

Please sign in to comment.