Skip to content

Commit f129edb

Browse files
committed
Fixed cases where user doesn't exist and comment sample data to match expected schema
1 parent 9de7e53 commit f129edb

File tree

12 files changed

+197
-284
lines changed

12 files changed

+197
-284
lines changed

src/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
### Directory Structure
22

33
*src* - Source code
4-
- *\_\_tests__*: Used by Jest in each folder to colocate tests.
5-
- *.next*: Next compiles things here.
6-
- *components*: React reusable components with GraphQL fragments colocated in the file.
4+
- *\_\_tests__*: Jest tests colocated in each folder.
5+
- *.next*: Next build files containing code-split modules and assets.
6+
- *components*: React components with GraphQL fragments colocated in-file.
77
- *data*: GraphQL Schema, HN Web APIs, cache, sample data.
8-
- - *models*: Data fetchers. Used to fetch data eg. in GraphQL schema resolvers.
9-
- *helpers*: Helpers for Apollo SSR and calculating 'time ago'.
10-
- *layouts*: Every page uses a layout. It's a React component that can have children put in it.
11-
- *pages*: Every .js file in here contains a React component that is served by Next with the name of the file as a route in the app.
8+
- - *models*: Data model. Used to create, fetch and set data eg. in GraphQL schema resolvers.
9+
- *helpers*: Helper functions and classes.
10+
- *layouts*: Every page uses a layout. It's a React component that can take children.
11+
- *pages*: React components served by Next as routes using file name in the app.
1212
- *static*: Static resources eg. favicon, css, gif.
13-
- *root* contains config files for app and Next. App entry point *server.js*.
13+
- The current folder contains config files and the app entry point *server.js*.

src/components/presentational/__tests__/Comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { shallow } from 'enzyme';
66
import Comment from '../Comment';
77
import data from '../../../data/SampleData';
88

9-
const comment = data.topStoriesCache[0].comments[0];
9+
const comment = data.comments[0];
1010
// Snapshot will be out of date if we don't use consistent time ago for comment
1111
// comment.creationTime = new Date().valueOf();
1212
MockDate.set(1506022129802);

src/components/presentational/__tests__/__snapshots__/CommentBox.js.snap

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,14 @@ ShallowWrapper {
9292
"_calledComponentWillUnmount": false,
9393
"_compositeType": 2,
9494
"_context": Object {},
95-
"_currentElement": <CommentBox
96-
comments={Array []}
97-
creationTime={1505863796000}
98-
id={15289630}
99-
submitterId="megous"
100-
text="It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through."
101-
/>,
95+
"_currentElement": <CommentBox />,
10296
"_debugID": 3,
10397
"_hostContainerInfo": null,
10498
"_hostParent": null,
10599
"_instance": StatelessComponent {
106100
"_reactInternalInstance": [Circular],
107101
"context": Object {},
108-
"props": Object {
109-
"comments": Array [],
110-
"creationTime": 1505863796000,
111-
"id": 15289630,
112-
"submitterId": "megous",
113-
"text": "It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through.",
114-
},
102+
"props": Object {},
115103
"refs": Object {},
116104
"state": null,
117105
"updater": Object {
@@ -220,13 +208,7 @@ ShallowWrapper {
220208
"render": [Function],
221209
},
222210
"root": [Circular],
223-
"unrendered": <CommentBox
224-
comments={Array []}
225-
creationTime={1505863796000}
226-
id={15289630}
227-
submitterId="megous"
228-
text="It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through."
229-
/>,
211+
"unrendered": <CommentBox />,
230212
}
231213
`;
232214

@@ -322,26 +304,14 @@ ShallowWrapper {
322304
"_calledComponentWillUnmount": false,
323305
"_compositeType": 2,
324306
"_context": Object {},
325-
"_currentElement": <CommentBox
326-
comments={Array []}
327-
creationTime={1505863796000}
328-
id={15289630}
329-
submitterId="megous"
330-
text="It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through."
331-
/>,
307+
"_currentElement": <CommentBox />,
332308
"_debugID": 5,
333309
"_hostContainerInfo": null,
334310
"_hostParent": null,
335311
"_instance": StatelessComponent {
336312
"_reactInternalInstance": [Circular],
337313
"context": Object {},
338-
"props": Object {
339-
"comments": Array [],
340-
"creationTime": 1505863796000,
341-
"id": 15289630,
342-
"submitterId": "megous",
343-
"text": "It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through.",
344-
},
314+
"props": Object {},
345315
"refs": Object {},
346316
"state": null,
347317
"updater": Object {
@@ -450,13 +420,7 @@ ShallowWrapper {
450420
"render": [Function],
451421
},
452422
"root": [Circular],
453-
"unrendered": <CommentBox
454-
comments={Array []}
455-
creationTime={1505863796000}
456-
id={15289630}
457-
submitterId="megous"
458-
text="It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through."
459-
/>,
423+
"unrendered": <CommentBox />,
460424
}
461425
`;
462426

@@ -552,26 +516,14 @@ ShallowWrapper {
552516
"_calledComponentWillUnmount": false,
553517
"_compositeType": 2,
554518
"_context": Object {},
555-
"_currentElement": <CommentBox
556-
comments={Array []}
557-
creationTime={1505863796000}
558-
id={15289630}
559-
submitterId="megous"
560-
text="It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through."
561-
/>,
519+
"_currentElement": <CommentBox />,
562520
"_debugID": 1,
563521
"_hostContainerInfo": null,
564522
"_hostParent": null,
565523
"_instance": StatelessComponent {
566524
"_reactInternalInstance": [Circular],
567525
"context": Object {},
568-
"props": Object {
569-
"comments": Array [],
570-
"creationTime": 1505863796000,
571-
"id": 15289630,
572-
"submitterId": "megous",
573-
"text": "It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through.",
574-
},
526+
"props": Object {},
575527
"refs": Object {},
576528
"state": null,
577529
"updater": Object {
@@ -680,12 +632,6 @@ ShallowWrapper {
680632
"render": [Function],
681633
},
682634
"root": [Circular],
683-
"unrendered": <CommentBox
684-
comments={Array []}
685-
creationTime={1505863796000}
686-
id={15289630}
687-
submitterId="megous"
688-
text="It is part of it in this case. You&#x27;ve just eliminated most of non-targeted scanners. Your log is much more readable and what is left will probably be dedicated attackers.<p>This might help in forensic investigation afterwards. Less crap to wade through."
689-
/>,
635+
"unrendered": <CommentBox />,
690636
}
691637
`;

0 commit comments

Comments
 (0)