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

@gooddata/test-storybook

Package Overview
Dependencies
Maintainers
37
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gooddata/test-storybook - npm Package Compare versions

Comparing version 0.1.0-pavelzgdc-ocetnik-doc-test-storybook-2017-12-07T16-32-12-844Z to 0.1.0-pavelzgdc-test-storybook-ignore-no-wrap-2017-12-11T14-13-19-304Z

.idea/misc.xml

2

index.d.ts

@@ -1,1 +0,1 @@

export const SCREENSHOT_WRAPPER_CLASS: string;
export const screenshotWrap: Function;
{
"name": "@gooddata/test-storybook",
"version": "0.1.0-pavelzgdc-ocetnik-doc-test-storybook-2017-12-07T16-32-12-844Z",
"version": "0.1.0-pavelzgdc-test-storybook-ignore-no-wrap-2017-12-11T14-13-19-304Z",
"description": "Visual regression testing for Storybook",
"main": "src/index.js",
"typings": "./index.d.ts",
"bin": {

@@ -22,8 +23,7 @@ "run-backstop": "src/run-backstop.js",

"enzyme": "3.2.0",
"enzyme-adapter-react-15.4": "1.0.5",
"enzyme-adapter-react-16": "1.1.0",
"eslint-config-gooddata": "0.0.15",
"jest": "21.2.1",
"react": "15.3.2",
"react-addons-test-utils": "15.3.2",
"react-dom": "15.3.2"
"react": "16.2.0",
"react-dom": "16.2.0"
},

@@ -41,3 +41,6 @@ "dependencies": {

"react": "*"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js"
}
}

@@ -14,3 +14,4 @@ const React = require('react');

module.exports = {
SCREENSHOT_WRAPPER_CLASS,
screenshotWrap
};

@@ -36,4 +36,3 @@ #! /usr/bin/env node

const command = program.reference ? 'reference' : 'test';
console.log(`running backstopjs("${command}", config)`);
backstopjs(command, { config });
const React = require('react');
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-15.4');
const index = require('../index');
enzyme.configure({ adapter: new Adapter() });
const InnerComponent = React.createElement('div', { className: 'inner-component' });
describe('index', () => {
describe('screenshotWrap', () => {
it('should wrap component', () => {

@@ -12,0 +10,0 @@ const wrappedComponent = enzyme.mount(index.screenshotWrap(InnerComponent));

@@ -12,6 +12,6 @@ const acornBase = require('acorn');

function getTokens(data) {
function getTokens(source) {
try {
// tokenizer() returns object so we need to convert it to array
return [...acorn.tokenizer(data, {
return [...acorn.tokenizer(source, {
plugins: {

@@ -28,18 +28,23 @@ jsx: true,

function isKind(tokens, token, i) {
return token.value === 'storiesOf' && tokens[i + 1].type.label === '(';
function isKind(tokens, i) {
return tokens[i].value === 'storiesOf' && tokens[i + 1].type.label === '(';
}
function isStory(tokens, token, i) {
return token.value === 'add' && tokens[i - 1].type.label === '.' && tokens[i + 1].type.label === '(';
function isStory(tokens, i) {
return tokens[i].value === 'add' && tokens[i - 1].type.label === '.' && tokens[i + 1].type.label === '(';
}
function parseKinds(data) {
function isScreenshotWrap(tokens, i) {
return tokens[i].type.label === 'name' && tokens[i].value === 'screenshotWrap' && tokens[i + 1].type.label === '(';
}
function parseKinds(source) {
let currentKind = null;
let lastStory = null;
const tokens = getTokens(data);
const tokens = getTokens(source);
const kinds = [];
for (let i = 0; i < tokens.length; i += 1) {
const token = tokens[i];
if (isKind(tokens, token, i)) {
if (isKind(tokens, i)) {
currentKind = tokens[i + 2].value;

@@ -53,7 +58,11 @@ kinds.push({

if (isStory(tokens, token, i)) {
const story = tokens[i + 2].value;
kinds[kinds.length - 1].stories.push(story);
if (isStory(tokens, i)) {
lastStory = tokens[i + 2].value;
i += 2;
}
if (lastStory && isScreenshotWrap(tokens, i)) {
kinds[kinds.length - 1].stories.push(lastStory);
lastStory = null;
}
}

@@ -65,13 +74,11 @@

function mapKindToScenario(kind, port) {
return kind.stories.map((story) => {
return {
url: `http://localhost:${port}/iframe.html?selectedKind=${encodeURIComponent(kind.kind)}&selectedStory=${encodeURIComponent(story)}`,
label: `${kind.kind} - ${story}`,
selectors: [`.${SCREENSHOT_WRAPPER_CLASS}`]
};
});
return kind.stories.map((story) => ({
url: `http://localhost:${port}/iframe.html?selectedKind=${encodeURIComponent(kind.kind)}&selectedStory=${encodeURIComponent(story)}`,
label: `${kind.kind} - ${story}`,
selectors: [`.${SCREENSHOT_WRAPPER_CLASS}`]
}));
}
function getScenarios(port) {
const fileNames = glob.sync('./stories/**/*.jsx');
const fileNames = glob.sync('./stories/**/*.{jsx,tsx}');

@@ -81,4 +88,4 @@ const kinds = flatten(

.map((fileName) => {
const data = fs.readFileSync(fileName, 'utf8');
return parseKinds(data);
const source = fs.readFileSync(fileName, 'utf8');
return parseKinds(source);
})

@@ -85,0 +92,0 @@ .filter(k => k.length > 0)

Sorry, the diff of this file is not supported yet

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