Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('renders correctly', () => {
const props = {
region: mockRegion,
save: mock.fn(),
load: mock.fn(),
create: mock.fn(),
deleteRegion: mock.fn(),
setLocally: mock.fn(),
setCenter: mock.fn()
}
// mount component
const {snapshot} = mockWithProvider()
expect(snapshot()).toMatchSnapshot()
const noCalls = [
'save',
'load',
'setLocally',
'setCenter'
]
noCalls.forEach(fn => {
expect(props[fn]).not.toBeCalled()
import { MuiThemeProvider } from '@material-ui/core/styles';
import { getByText, render, waitForDomChange } from '@testing-library/react';
import jest from 'jest-mock';
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import API from '../../api/API';
import ApplicationItemGroupItem from '../../components/Applications/ApplicationItemGroupItem';
import { theme } from '../../TestHelpers/theme';
function mockResolver() {
return Promise.resolve(1);
}
const mockAjax = jest.fn(() => mockResolver);
describe('Application Item Group Item', () => {
const minProps = {
group: {
name: 'ABC',
application_id: '123',
id: '1',
channel: {
name: 'main',
},
},
appName: 'FlatCar',
};
beforeEach(() => {
API.getInstancesCount = mockAjax();
});
it('should render correct link and correct total instances', async () => {
it('renders correctly', () => {
const tree = renderer.create(
<map>
</map>
).toJSON()
expect(tree).toMatchSnapshot()
})
})
const jestMock = require('jest-mock')
module.exports = jestMock.fn(() => {
throw new Error('Ooops!')
})
export default function(history, done) {
const spy = mock.fn();
const unlisten = history.listen(spy);
expect(spy).not.toHaveBeenCalled();
unlisten();
done();
}
export function getMetricsManagerForTest(): MetricsManager {
const mm = new MetricsManager()
mm["track"] = jest.fn()
mm["identify"] = jest.fn()
return mm
}
resetMock() {
this.request = mock.fn((input, options) => this._request());
}