/
githubmirror
/
react-beautiful-dnd
Обзор
Документация
Войти
/
githubmirror
/
react-beautiful-dnd
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/util/console.js
31 строка
788 B
Alex Reardon
12.0 (#1487)
29 окт 2019, 01:40
Не верифицирован
29 окт 2019, 01:40
24a8e60
Код
Авторство
О чём код?
// @flow import { noop } from '../../src/empty'; function withConsole(type: string, fn: () => void, message?: string) { const mock = jest.spyOn(console, type).mockImplementation(noop); fn(); expect(mock).toHaveBeenCalled(); if (message) { expect(mock).toHaveBeenCalledWith(expect.stringContaining(message)); } mock.mockReset(); } export const withError = withConsole.bind(null, 'error'); export const withWarn = withConsole.bind(null, 'warn'); function withoutConsole(type: string, fn: () => void) { const mock = jest.spyOn(console, type).mockImplementation(noop); fn(); expect(mock).not.toHaveBeenCalled(); mock.mockReset(); } export const withoutError = withoutConsole.bind(null, 'error'); export const withoutWarn = withoutConsole.bind(null, 'warn');