Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { createStore } from 'redux';
import { Provider, connect, connectAdvanced } from '../';
import { render, options } from 'preact';
import React from 'preact';
import * as Redux from '../dist/preact-redux.esm.js';
// disable async rendering entirely to make tests simpler
options.debounceRendering = f => f();
describe('preact-redux', () => {
it('should export Provider & connect', () => {
expect(Provider).to.be.a('function');
expect(connect).to.be.a('function');
});
describe('', () => {
it('should commit store prop to context', () => {
let store = createStore( a => a );
let Child = sinon.stub().returns(<div>);
render((
</div>
import { h, Component, options } from 'preact';
import LoadingIndicator from 'components/LoadingIndicator';
import TweetList from 'components/TweetList';
import TweetStream from './TweetStream';
import config from '../../config';
// Use requestAnimationFrame by default but allow URL param to disable.
options.debounceRendering = location.search.indexOf('raf=false') < 0
? requestAnimationFrame
: null;
export default class Timeline extends Component {
state = {
tweets: [],
};
componentDidMount() {
this._tweetStream = new TweetStream();
this._fetchTweets();
}
render() {
const { authenticated, disableMedia, tweets } = this.state;
describe('Async Route', () => {
options.syncComponentUpdates = false;
options.debounceRendering = f => f();
class SampleTag extends Component {
render(){
return (<h1>hi</h1>);
}
}
class ParameterizedSampleTag extends Component {
render(){
return (<h1>hi - {this.props.matches.pid}</h1>);
}
}
it('should call the given function on mount', () => {
let getComponent = sinon.spy();
render(, document.createElement('div'));
expect(getComponent).called;
});
beforeEach(() => {
options.debounceRendering = r => r();
render();
});
export function setupRerender() {
options.__test__previousDebounce = options.debounceRendering;
options.debounceRendering = cb => (options.__test__drainQueue = cb);
return () => options.__test__drainQueue && options.__test__drainQueue();
}
export function setupRerender() {
Component.__test__previousDebounce = options.debounceRendering;
options.debounceRendering = cb => Component.__test__drainQueue = cb;
return () => Component.__test__drainQueue && Component.__test__drainQueue();
}
export function setupRerender() {
Component.__test__previousDebounce = options.debounceRendering;
options.debounceRendering = cb => Component.__test__drainQueue = cb;
return () => Component.__test__drainQueue && Component.__test__drainQueue();
}
export function installHook() {
if (hookInstalled) {
return;
}
const origDebounce = options.debounceRendering || defer;
function trackPendingRender(callback: () => any) {
pendingCallbacks.add(callback);
origDebounce.call(null, callback);
}
options.debounceRendering = trackPendingRender;
hookInstalled = true;
}
export function installHook() {
if (hookInstalled) {
return;
}
const origDebounce = options.debounceRendering || defer;
function trackPendingRender(callback: () => any) {
pendingCallbacks.add(callback);
origDebounce.call(null, callback);
}
options.debounceRendering = trackPendingRender;
hookInstalled = true;
}
import { render, options } from "preact";
import Router from "universal-router";
import { updateTitle } from "./lib/updateTag";
import history from "./lib/history";
import Provider from "./lib/ContextProvider";
import UseScroll from "./lib/useScroll";
import registerServiceWorker from "./sw-register";
import store from "./store";
import routes from "./routes";
let CURRENT_LOCATION = history.location;
let FIRST_RENDER = true;
options.debounceRendering = requestAnimationFrame;
const scroll = new UseScroll(CURRENT_LOCATION);
const routerMiddleware = {
preMiddleware() {
return scroll.storeScroll(history);
},
postMiddleware({ title }) {
updateTitle(title);
scroll.restoreScroll(history.location);
}
};
function insertCss(...styles) {
const removeCss = styles.map(x => x._insertCss());