New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-cosmos

Package Overview
Dependencies
Maintainers
1
Versions
519
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cosmos - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0-beta.8

5

lib/index.js

@@ -44,2 +44,3 @@ 'use strict';

var fixtures = _ref.fixtures;
var containerQuerySelector = _ref.containerQuerySelector;

@@ -52,4 +53,6 @@ var firstProxy = (0, _linkedList2.default)([].concat(_toConsumableArray(proxies), [

var container = containerQuerySelector ? document.querySelector(containerQuerySelector) : document.body.appendChild(document.createElement('div'));
return new _reactQuerystringRouter2.default.Router({
container: document.body.appendChild(document.createElement('div')),
container: container,
defaultProps: {

@@ -56,0 +59,0 @@ firstProxy: firstProxy,

2

lib/proxies/StateProxy.js

@@ -139,3 +139,3 @@ 'use strict';

// TODO: No longer omit when props will be read from fixture.props
// https://github.com/skidding/react-cosmos/issues/217
// https://github.com/react-cosmos/react-cosmos/issues/217

@@ -142,0 +142,0 @@ var childFixture = disableLocalState ? fixture : (0, _lodash2.default)(fixture, 'state');

{
"name": "react-cosmos",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.8",
"description": "The glue between the React Cosmos modules",
"repository": "https://github.com/skidding/react-cosmos/tree/master/packages/react-cosmos",
"repository": "https://github.com/react-cosmos/react-cosmos/tree/master/packages/react-cosmos",
"license": "MIT",

@@ -11,5 +11,5 @@ "main": "lib/index.js",

"lodash.omit": "^4.5.0",
"react-component-playground": "^1.0.0-beta.5",
"react-component-tree": "^1.0.0-beta.5",
"react-querystring-router": "^1.0.0-beta.5"
"react-component-playground": "^1.0.0-beta.8",
"react-component-tree": "^1.0.0-beta.8",
"react-querystring-router": "^1.0.0-beta.8"
},

@@ -16,0 +16,0 @@ "peerDependencies": {

@@ -24,47 +24,98 @@ const FakeRouter = jest.fn();

const routerInstance = startReactCosmos({
proxies: fakeProxies,
components: fakeComponentsInput,
fixtures: fakeFixturesInput,
});
let routerInstance;
it('uses Componet Playground as router component class', () => {
const { getComponentClass } = FakeRouter.mock.calls[0][0];
expect(getComponentClass()).toBe(FakeComponentPlayground);
});
const initRouter = (options) => {
jest.clearAllMocks();
routerInstance = startReactCosmos(options);
};
it('create proxy list with user proxies', () => {
expect(createLinkedList.mock.calls[0][0][0]).toBe(fakeProxies[0]);
expect(createLinkedList.mock.calls[0][0][1]).toBe(fakeProxies[1]);
});
const commonTests = () => {
it('uses Componet Playground as router component class', () => {
const { getComponentClass } = FakeRouter.mock.calls[0][0];
expect(getComponentClass()).toBe(FakeComponentPlayground);
});
it('end proxy list with internal proxies', () => {
expect(createLinkedList.mock.calls[0][0][3]).toBe(PreviewLoader);
});
it('create proxy list with user proxies', () => {
expect(createLinkedList.mock.calls[0][0][0]).toBe(fakeProxies[0]);
expect(createLinkedList.mock.calls[0][0][1]).toBe(fakeProxies[1]);
});
it('sends proxy list to Component Playground props', () => {
const { firstProxy } = FakeRouter.mock.calls[0][0].defaultProps;
expect(firstProxy).toBe(fakeLinkedList);
});
it('end proxy list with internal proxies', () => {
expect(createLinkedList.mock.calls[0][0][3]).toBe(PreviewLoader);
});
it('sends components input to loadComponents lib', () => {
expect(fakeLoadComponents.mock.calls[0][0]).toBe(fakeComponentsInput);
});
it('sends proxy list to Component Playground props', () => {
const { firstProxy } = FakeRouter.mock.calls[0][0].defaultProps;
expect(firstProxy).toBe(fakeLinkedList);
});
it('sends fixtures input to loadFixtures lib', () => {
expect(fakeLoadFixtures.mock.calls[0][0]).toBe(fakeFixturesInput);
});
it('sends components input to loadComponents lib', () => {
expect(fakeLoadComponents.mock.calls[0][0]).toBe(fakeComponentsInput);
});
it('sends components output to Component Playground props', () => {
const { components } = FakeRouter.mock.calls[0][0].defaultProps;
expect(components).toBe(fakeComponentsOutput);
});
it('sends fixtures input to loadFixtures lib', () => {
expect(fakeLoadFixtures.mock.calls[0][0]).toBe(fakeFixturesInput);
});
it('sends fixtures output to Component Playground props', () => {
const { fixtures } = FakeRouter.mock.calls[0][0].defaultProps;
expect(fixtures).toBe(fakeFixturesOutput);
it('sends components output to Component Playground props', () => {
const { components } = FakeRouter.mock.calls[0][0].defaultProps;
expect(components).toBe(fakeComponentsOutput);
});
it('sends fixtures output to Component Playground props', () => {
const { fixtures } = FakeRouter.mock.calls[0][0].defaultProps;
expect(fixtures).toBe(fakeFixturesOutput);
});
it('returns router instance', () => {
expect(routerInstance).toBeInstanceOf(FakeRouter);
});
};
describe('without container query selector', () => {
beforeAll(() => {
initRouter({
proxies: fakeProxies,
components: fakeComponentsInput,
fixtures: fakeFixturesInput,
});
});
commonTests();
it('uses element inside document body for router container', () => {
const { container } = FakeRouter.mock.calls[0][0];
expect(container.parentNode).toBe(document.body);
});
});
it('returns router instance', () => {
expect(routerInstance).toBeInstanceOf(FakeRouter);
describe('with container query selector', () => {
let rootEl;
beforeAll(() => {
rootEl = window.document.createElement('div', { id: 'root' });
rootEl.id = 'app';
document.body.appendChild(rootEl);
initRouter({
proxies: fakeProxies,
components: fakeComponentsInput,
fixtures: fakeFixturesInput,
containerQuerySelector: '#app',
});
});
afterAll(() => {
document.body.removeChild(rootEl);
});
commonTests();
it('uses queried element for router container', () => {
const { container } = FakeRouter.mock.calls[0][0];
// For some reason expect(container).toBe(rootEl) fills up the memory until
// it reaches a V8 limit and crashes due to allocation fail. Probably when
// pretty-format is used to display the pretty diff
expect(container === rootEl).toBe(true);
});
});

@@ -23,2 +23,3 @@ import ReactQuerystringRouter from 'react-querystring-router';

fixtures,
containerQuerySelector,
}) => {

@@ -33,4 +34,8 @@ const firstProxy = createLinkedList([

const container = containerQuerySelector ?
document.querySelector(containerQuerySelector) :
document.body.appendChild(document.createElement('div'));
return new ReactQuerystringRouter.Router({
container: document.body.appendChild(document.createElement('div')),
container,
defaultProps: {

@@ -37,0 +42,0 @@ firstProxy,

@@ -13,3 +13,3 @@ import React from 'react';

// TODO: Redesign fixture to read props from fixture.props (vs from root)
// https://github.com/skidding/react-cosmos/issues/217
// https://github.com/react-cosmos/react-cosmos/issues/217
...omit(fixture, ['component']),

@@ -16,0 +16,0 @@ ref: onPreviewRef,

@@ -98,3 +98,3 @@ import React from 'react';

// TODO: No longer omit when props will be read from fixture.props
// https://github.com/skidding/react-cosmos/issues/217
// https://github.com/react-cosmos/react-cosmos/issues/217
const childFixture = disableLocalState ? fixture : omit(fixture, 'state');

@@ -101,0 +101,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc