<commit_before>/*
 * Copyright (C) 2019 - 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 React from 'react'
import ViolationTray from '../ViolationTray'
import {render} from '@testing-library/react'

describe('Violation Tray', () => {
  beforeEach(() => {
    fetch.resetMocks()
  })

  const getProps = overrides => ({
    violations: [],
    whitelistedDomains: {account: []},
    ...overrides
  })

  it('displays a spinner when loading data', async () => {
    const {findByText} = render(<ViolationTray {...getProps()} />)
    // Even though there isn't an expect here... it's functionally the same,
    // if it doesn't find it... the test will fail :)
    await findByText('Loading')
  })
  it('displays an error alert when an error loading occurs', async () => {
    fetch.mockReject(new Error('fail'))
    const {findByText} = render(<ViolationTray {...getProps()} />)
    expect(await findByText(/Something went wrong loading/)).toBeInTheDocument()
  })

  it('displays an info alert when there are no violations', async () => {
    fetch.mockResponse(JSON.stringify([]))
    const {findByText} = render(<ViolationTray {...getProps()} />)
    expect(await findByText(/No violations/)).toBeInTheDocument()
  })
<commit_msg>Fix length issue ViolationTray.test.js<commit_after>/*
 * Copyright (C) 2019 - 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 React from 'react'
import ViolationTray from '../ViolationTray'
import {render} from '@testing-library/react'

describe('Violation Tray', () => {
  beforeEach(() => {
    fetch.resetMocks()
  })

  const getProps = overrides => ({
    violations: [],
    whitelistedDomains: {account: []},
    ...overrides
  })

  it('displays a spinner when loading data', async () => {
    fetch.mockResponse(JSON.stringify([]))
    const {findByText} = render(<ViolationTray {...getProps()} />)
    // Even though there isn't an expect here... it's functionally the same,
    // if it doesn't find it... the test will fail :)
    await findByText('Loading')
  })
  it('displays an error alert when an error loading occurs', async () => {
    fetch.mockReject(new Error('fail'))
    const {findByText} = render(<ViolationTray {...getProps()} />)
    expect(await findByText(/Something went wrong loading/)).toBeInTheDocument()
  })

  it('displays an info alert when there are no violations', async () => {
    fetch.mockResponse(JSON.stringify([]))
    const {findByText} = render(<ViolationTray {...getProps()} />)
    expect(await findByText(/No violations/)).toBeInTheDocument()
  })

{'fraction_non_alphanumeric': 0.12585571353343866, 'fraction_numerical': 0.0026329647182727752, 'mean_word_length': 3.6272838002436054, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '378766', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1078, 'n_words': 404}