░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
pplmvsvm
LOCATION:
/var/www/canvas/ui/features/speed_grader/react/__tests__
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: SpeedGraderStatusMenu.test.js
/* * Copyright (C) 2021 - present Instructure, Inc. * * This file is part of Canvas. * * Canvas is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3 of the License. * * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ import SpeedGraderStatusMenu from '../SpeedGraderStatusMenu' import React from 'react' import {fireEvent, render} from '@testing-library/react' describe('SpeedGraderStatusMenu', () => { let props const renderComponent = () => render(<SpeedGraderStatusMenu {...props} />) beforeEach(() => { window.ENV = {FEATURES: {}} props = { lateSubmissionInterval: 'day', locale: 'en', secondsLate: 0, selection: 'none', updateSubmission: jest.fn(), } }) function selectMenuItem(selection) { const {getByRole} = renderComponent() const trigger = getByRole('button', {name: /Edit status/i}) fireEvent.click(trigger) const menuItem = getByRole('menuitemradio', {name: selection}) fireEvent.click(menuItem) } function getTimeLateInput() { const searchString = props.lateSubmissionInterval === 'day' ? 'Days late' : 'Hours late' const {queryByRole} = renderComponent() return queryByRole('textbox', {name: searchString}) } it('renders the time late input when the selection is late', () => { props.selection = 'late' const timeLateInput = getTimeLateInput() expect(timeLateInput).toBeInTheDocument() }) it('does not render the time late input when the selection is not late', () => { const timeLateInput = getTimeLateInput() expect(timeLateInput).not.toBeInTheDocument() }) it('invokes updateSubmission prop callback when new selection does not match the old selection', () => { selectMenuItem('Missing') expect(props.updateSubmission).toHaveBeenCalledTimes(1) }) it('does not invoke updateSubmission prop callback when new selection matches the old selection', () => { selectMenuItem('None') expect(props.updateSubmission).toHaveBeenCalledTimes(0) }) it('invokes updateSubmission prop callback with "excuse: true" param when new selection is "excused"', () => { selectMenuItem('Excused') expect(props.updateSubmission).toHaveBeenLastCalledWith({excuse: true}) }) it('invokes updateSubmission prop callback with latePolicyStatus of "late" and a secondsLateOverride param when new selection is "late"', () => { selectMenuItem('Late') expect(props.updateSubmission).toHaveBeenLastCalledWith({ latePolicyStatus: 'late', secondsLateOverride: props.secondsLate, }) }) it('invokes updateSubmission prop callback with latePolicyStatus of "missing" when new selection is "missing"', () => { selectMenuItem('Missing') expect(props.updateSubmission).toHaveBeenLastCalledWith({latePolicyStatus: 'missing'}) }) it('invokes updateSubmission prop callback with latePolicyStatus of "none" when new selection is "none"', () => { props.selection = 'missing' selectMenuItem('None') expect(props.updateSubmission).toHaveBeenLastCalledWith({latePolicyStatus: 'none'}) }) })
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📄 CommentArea.test.js
JS
2.1 KB
2023-09-24 03:39
EDIT
📄 GradeLoadingSpinner.test.tsx
TSX
4.9 KB
2023-09-24 03:36
EDIT
📄 SpeedGraderStatusMenu.test.js
JS
3.5 KB
2023-09-24 03:39
EDIT