Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop branch #298

Merged
merged 2 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"graphql": "~0",
"graphql-tag": "^2.9.2",
"identity-obj-proxy": "^3.0.0",
"informed": "^1.9.0",
"intl": "^1.2.5",
"jest": "^23.4.0",
"jest-fetch-mock": "^1.4.1",
Expand All @@ -93,6 +94,7 @@
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"redux": "^4.0.0",
"redux-actions": "2.6.1",
"redux-thunk": "^2.3.0",
"rimraf": "^2.6.2",
"storybook-readme": "^3.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { createElement } from 'react';

export const mockRequest = jest.fn();

export const RestApi = {
Magento2: {
request: mockRequest
}
};

/**
* the Price component from @magento/peregrine
* has browser-specific functionality and cannot
Expand Down
56 changes: 28 additions & 28 deletions packages/venia-concept/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"name": "theme-frontend-venia",
"version": "0.1.1",
"description": "Venia PWA Concept Theme for Magento 2",
"license": "(OSL-3.0 OR AFL-3.0)",
"author": "Magento Commerce",
"main": "src/index.js",
"repository": "github:magento-research/pwa-studio",
"bugs": {
"url": "https://github.com/magento-research/pwa-studio/issues"
},
"homepage": "https://github.com/magento-research/pwa-studio/tree/master/packages/venia-concept#readme",
"scripts": {
"build": "webpack --color --env.phase production",
"clean": "rimraf web/js",
"prepare": "npm-merge-driver install",
"start": "webpack-dev-server --progress --color --env.phase development",
"start:debug": "node --inspect-brk ./node_modules/.bin/webpack-dev-server --progress --color --env.phase development",
"watch": "npm run -s start"
},
"dependencies": {},
"devDependencies": {
"@magento/peregrine": "*",
"@magento/pwa-buildpack": "*",
"npm-merge-driver": "^2.3.5",
"rimraf": "^2.6.2",
"webpack": "3.11.0",
"webpack-dev-server": "2.11.0"
}
"name": "theme-frontend-venia",
"version": "0.1.1",
"description": "Venia PWA Concept Theme for Magento 2",
"license": "(OSL-3.0 OR AFL-3.0)",
"author": "Magento Commerce",
"main": "src/index.js",
"repository": "github:magento-research/pwa-studio",
"bugs": {
"url": "https://github.com/magento-research/pwa-studio/issues"
},
"homepage": "https://github.com/magento-research/pwa-studio/tree/master/packages/venia-concept#readme",
"scripts": {
"build": "webpack --color --env.phase production",
"clean": "rimraf web/js",
"prepare": "npm-merge-driver install",
"start": "webpack-dev-server --progress --color --env.phase development",
"start:debug": "node --inspect-brk ./node_modules/.bin/webpack-dev-server --progress --color --env.phase development",
"watch": "npm run -s start"
},
"dependencies": {},
"devDependencies": {
"@magento/peregrine": "*",
"@magento/pwa-buildpack": "*",
"npm-merge-driver": "^2.3.5",
"rimraf": "^2.6.2",
"webpack": "3.11.0",
"webpack-dev-server": "2.11.0"
}
}
7 changes: 7 additions & 0 deletions packages/venia-concept/src/__mocks__/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const initialState = {};

export const addReducer = jest.fn();
export const dispatch = jest.fn();
export const getState = jest.fn(() => initialState);

export default { addReducer, dispatch, getState };
15 changes: 0 additions & 15 deletions packages/venia-concept/src/actions/app.js

This file was deleted.

20 changes: 20 additions & 0 deletions packages/venia-concept/src/actions/app/__tests__/actions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import actions from '../actions';

const payload = 'FOO';
const error = new Error('BAR');

test('toggleDrawer.toString() returns the proper action type', () => {
expect(actions.toggleDrawer.toString()).toBe('APP/TOGGLE_DRAWER');
});

test('toggleDrawer() returns a proper action object', () => {
expect(actions.toggleDrawer(payload)).toEqual({
type: 'APP/TOGGLE_DRAWER',
payload
});
expect(actions.toggleDrawer(error)).toEqual({
type: 'APP/TOGGLE_DRAWER',
payload: error,
error: true
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { dispatch, getState } from 'src/store';
import actions from '../actions';
import { closeDrawer, toggleDrawer } from '../asyncActions';

jest.mock('src/store');

const thunkArgs = [dispatch, getState];

afterEach(() => {
dispatch.mockClear();
});

test('toggleDrawer() to return a thunk', () => {
expect(toggleDrawer()).toBeInstanceOf(Function);
});

test('toggleDrawer thunk returns undefined', async () => {
const payload = 'FOO';
const result = await toggleDrawer(payload)(...thunkArgs);

expect(result).toBeUndefined();
});

test('toggleDrawer thunk dispatches actions', async () => {
const payload = 'FOO';
await toggleDrawer(payload)(...thunkArgs);

expect(dispatch).toHaveBeenCalledWith(actions.toggleDrawer(payload));
expect(dispatch).toHaveBeenCalledTimes(1);
});

test('closeDrawer() to return a thunk ', () => {
expect(closeDrawer()).toBeInstanceOf(Function);
});

test('closeDrawer thunk returns undefined', async () => {
const result = await closeDrawer()(...thunkArgs);

expect(result).toBeUndefined();
});

test('closeDrawer thunk dispatches actions', async () => {
await closeDrawer()(...thunkArgs);

expect(dispatch).toHaveBeenCalledWith(actions.toggleDrawer(null));
expect(dispatch).toHaveBeenCalledTimes(1);
});
6 changes: 6 additions & 0 deletions packages/venia-concept/src/actions/app/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createActions } from 'redux-actions';

const prefix = 'APP';
const actionTypes = ['TOGGLE_DRAWER'];

export default createActions(...actionTypes, { prefix });
7 changes: 7 additions & 0 deletions packages/venia-concept/src/actions/app/asyncActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import actions from './actions';

export const toggleDrawer = name => async dispatch =>
dispatch(actions.toggleDrawer(name));

export const closeDrawer = () => async dispatch =>
dispatch(actions.toggleDrawer(null));
2 changes: 2 additions & 0 deletions packages/venia-concept/src/actions/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './actions';
export * from './asyncActions';
Loading