Skip to content

Commit 65ada84

Browse files
author
Andrew Levine
committed
Super basic implementation of category page using apollo client for data fetching
1 parent edd2b1c commit 65ada84

File tree

14 files changed

+501
-164
lines changed

14 files changed

+501
-164
lines changed

packages/peregrine/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"url": "https://github.com/magento-research/peregrine"
1414
},
1515
"scripts": {
16-
"build": "babel src -d dist --ignore test.js",
16+
"build": "babel src -d dist --ignore '*.test.js,*.spec.js'",
1717
"danger": "danger-ci",
1818
"clean": "rimraf dist",
1919
"prepare": "npm-merge-driver install",

packages/peregrine/src/List/__tests__/items.spec.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,38 @@ import { Items } from '..';
66

77
configure({ adapter: new Adapter() });
88

9-
const items = Object.entries({
10-
a: { id: 'a', val: '10' },
11-
b: { id: 'b', val: '20' },
12-
c: { id: 'c', val: '30' }
13-
});
9+
const items = [
10+
[
11+
1,
12+
{
13+
id: 1,
14+
name: 'Test Product 1',
15+
small_image: '/test/product/1.png',
16+
price: {
17+
regularPrice: {
18+
amount: {
19+
value: 100
20+
}
21+
}
22+
}
23+
}
24+
],
25+
[
26+
2,
27+
{
28+
id: 2,
29+
name: 'Test Product 2',
30+
small_image: '/test/product/2.png',
31+
price: {
32+
regularPrice: {
33+
amount: {
34+
value: 100
35+
}
36+
}
37+
}
38+
}
39+
]
40+
];
1441

1542
test('renders a fragment', () => {
1643
const props = { items };
@@ -61,7 +88,7 @@ test('passes correct props to each child', () => {
6188
wrapper.children().forEach((node, i) => {
6289
const [key, item] = items[i];
6390

64-
expect(node.key()).toEqual(key);
91+
expect(node.key()).toEqual(key.toString());
6592
expect(node.props()).toMatchObject({
6693
item,
6794
render: props.renderItem,
@@ -158,13 +185,13 @@ test('updates radio `selection` on child click', () => {
158185
expect(wrapper.state('selection')).toEqual(new Set());
159186

160187
wrapper.childAt(0).simulate('click');
161-
expect(wrapper.state('selection')).toEqual(new Set(['a']));
188+
expect(wrapper.state('selection')).toEqual(new Set([1]));
162189

163190
wrapper.childAt(1).simulate('click');
164-
expect(wrapper.state('selection')).toEqual(new Set(['b']));
191+
expect(wrapper.state('selection')).toEqual(new Set([2]));
165192

166193
wrapper.childAt(0).simulate('click');
167-
expect(wrapper.state('selection')).toEqual(new Set(['a']));
194+
expect(wrapper.state('selection')).toEqual(new Set([1]));
168195
});
169196

170197
test('updates checkbox `selection` on child click', () => {
@@ -174,13 +201,13 @@ test('updates checkbox `selection` on child click', () => {
174201
expect(wrapper.state('selection')).toEqual(new Set());
175202

176203
wrapper.childAt(0).simulate('click');
177-
expect(wrapper.state('selection')).toEqual(new Set(['a']));
204+
expect(wrapper.state('selection')).toEqual(new Set([1]));
178205

179206
wrapper.childAt(1).simulate('click');
180-
expect(wrapper.state('selection')).toEqual(new Set(['a', 'b']));
207+
expect(wrapper.state('selection')).toEqual(new Set([1, 2]));
181208

182209
wrapper.childAt(0).simulate('click');
183-
expect(wrapper.state('selection')).toEqual(new Set(['b']));
210+
expect(wrapper.state('selection')).toEqual(new Set([2]));
184211
});
185212

186213
test('calls `syncSelection` after updating selection', () => {

packages/venia-concept/babel.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const plugins = [
77
'syntax-jsx',
88
'transform-class-properties',
99
'transform-object-rest-spread',
10-
['transform-react-jsx', { pragma: 'createElement' }]
10+
['transform-react-jsx', { pragma: 'createElement' }],
11+
'graphql-tag'
1112
];
1213

1314
// define default babel options

0 commit comments

Comments
 (0)