Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global describe, it, beforeEach, afterEach */
import React, { Component, PropTypes } from 'react'
import { render, unmountComponentAtNode } from 'react-dom'
import { findRenderedDOMComponentWithTag, Simulate } from 'react-addons-test-utils'
import { Route, Router, Link, Redirect, RouteStack, connectHistory } from '../src'
import { createMemoryHistory } from 'history'
import expect from 'expect'
import expectJSX from 'expect-jsx'
expect.extend(expectJSX)
describe('Router', () => {
let node
beforeEach(() => node = document.createElement('div'))
afterEach(() => unmountComponentAtNode(node))
it('will introduce a `history` context', done => {
class App extends Component {
static contextTypes = {
history: PropTypes.object
}
componentDidMount() {
expect(this.context.history).toExist()
done()
}
/* global describe, it */
import React, {Component, PropTypes} from 'react';
import {Router, Route} from '../src';
import {renderToString, renderToStaticMarkup} from 'react-dom/server';
import {createMemoryHistory} from 'history';
import expect from 'expect';
import expectJSX from 'expect-jsx';
expect.extend(expectJSX);
describe('server side routah', () => {
it('prop: history', done => {
class App extends Component{
static contextTypes = {
history: PropTypes.object
};
componentWillMount(){
this.context.history.listen(l => expect(l.pathname).toEqual('/xyz'))();
done();
}
render(){
return null;
}
}
// declare var babelHelpers: any
// Object.assign(babelHelpers, { applyDecoratedDescriptor, initializerDefineProperty })
// import "@babel/runtime"
import chalk from "chalk"
import Enzyme from "enzyme"
import Adapter from "enzyme-adapter-react-16"
import expect from "expect"
import { format } from "util"
import "lib/tests/renderUntil"
Enzyme.configure({ adapter: new Adapter() })
// Waiting on https://github.com/thymikee/snapshot-diff/pull/17
import diff from "snapshot-diff"
expect.extend({ toMatchDiffSnapshot: (diff as any).toMatchDiffSnapshot })
jest.mock("react-tracking")
import _track from "react-tracking"
const track = _track as jest.Mock
track.mockImplementation((_ => x => x) as any)
// Mock this separately so react-tracking can be unmocked in tests but not result in the `window` global being accessed.
jest.mock("react-tracking/build/dispatchTrackingEvent")
jest.mock("./lib/NativeModules/NotificationsManager.tsx", () => ({
NotificationsManager: {
addListener: jest.fn(),
},
}))
jest.mock("@mapbox/react-native-mapbox-gl", () => ({
import React from 'react';
import expect from 'expect';
import expectJSX from 'expect-jsx';
import TransitionGroup from 'react/lib/ReactCSSTransitionGroup';
import {
defaultValues,
className,
transition,
Notifications
} from '../../src/components/Notifications/Notifications';
import {className as notificationClassName} from '../../src/components/Notification/Notification';
import STATUS from '../../src/constants';
import {shallowRender, render} from '../helpers';
expect.extend(expectJSX);
describe('Notifications', () => {
it('should render component with correct JSX structure', () => {
const component = shallowRender(Notifications);
let expectedElement = (
<div>
</div>
);
expect(component).toEqualJSX(expectedElement);
});
it('should render component with its default props', () => {
import 'babel-polyfill';
import moment from 'moment';
import expect from 'expect';
import expectJSX from 'expect-jsx';
import sinon from 'sinon';
import chai from 'chai';
import chaiEnzyme from 'chai-enzyme';
chai.use(chaiEnzyme());
moment.locale('nb-NO');
expect.extend(expectJSX);
global.chai = chai;
global.sinon = sinon;
global.expect = chai.expect;
global.should = chai.should();
global.window = document.defaultView;
global.navigator = global.window.navigator;
const context = require.context('../app', true, /.spec\.js$/);
context.keys().forEach(context);
import test from "jest-ava-api"
import React from "react"
import { createRenderer } from "react-addons-test-utils"
import expect from "expect"
import expectJSX from "expect-jsx"
import BodyContainer from "../index.js"
expect.extend(expectJSX)
const Noop = () => {}
test("should wrap html", () => {
const html = "<a>test</a>"
const renderer = createRenderer()
renderer.render(
{ html }
)
expect(renderer.getRenderOutput()).toEqualJSX(
<div>
)
})
</div>
import expect from 'expect';
import expectJSX from 'expect-jsx';
expect.extend(expectJSX);
import React, { Component } from 'react';
import {render} from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import ScrollArea from '../src/js/ScrollArea';
import Scrollbar from '../src/js/Scrollbar';
function setup(props, sizes){
let renderer = TestUtils.createRenderer();
renderer.render(<p>content</p>);
let instance = getRendererComponentInstance(renderer);
if(sizes){
instance.computeSizes = () => sizes;
instance.setSizesToState();
}
import 'babel-polyfill';
import expect from 'expect';
import expectJSX from 'expect-jsx';
expect.extend(expectJSX);
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { Panel } from './../src/';
function setup() {
let renderer = TestUtils.createRenderer();
renderer.render()
let output = renderer.getRenderOutput();
return {
output,
renderer
}
}
describe('components', () => {
import expect from 'expect';
import path from 'path';
import { createProgram, getPreEmitDiagnostics } from 'typescript';
expect.extend({
toCompile(received) {
let diagnostics = compile(received);
let pass = diagnostics.length == 0;
if (pass) {
return {
pass,
message: () =>
`expected '${received}' to compile with errors, but it compiled cleanly`
};
} else {
return {
pass,
message: () =>
`expected '${received}' to compile without errors, but it failed:
${formatTypescriptDiagnostics(diagnostics)}`