forked from ReactFinland/content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
106 lines (91 loc) · 2.55 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const assert = require("assert");
const graphql = require("graphql").graphql;
const { makeExecutableSchema } = require("graphql-tools");
const { schema, content } = require("./");
assert.equal(
content.workshops.find(o => o.title === "Styleguide-driven Development")
.speakers[0].name,
"Andrey Okonetchnikov"
);
assert.equal(
content.speakers.find(o => o.name === "Andrey Okonetchnikov").workshops[0]
.title,
content.workshops.find(o => o.title === "Styleguide-driven Development").title
);
assert.equal(
content.speakers.find(o => o.name === "Christian Alfoni").presentations[0]
.title,
content.presentations.find(
o => o.title === "Declarative state and side effects"
).title
);
assert.equal(
content.speakers.find(o => o.name === "Christian Alfoni").presentations[0]
.title,
content.talks.find(o => o.title === "Declarative state and side effects")
.title
);
assert.equal(
content.speakers.find(o => o.name === "Jani Eväkallio").keynotes[0].title,
content.keynotes.find(o => o.title === "The New Best Practices").title
);
assert.equal(
content.speakers.find(o => o.name === "Jani Eväkallio").keynotes[0].title,
content.talks.find(o => o.title === "The New Best Practices").title
);
assert.equal(
content.speakers.find(o => o.name === "Varya Stepanova").lightningTalks[0]
.title,
content.lightningTalks.find(
o =>
o.title ===
"How to use React, webpack and other buzzwords if there is no need"
).title
);
assert.equal(
content.speakers.find(o => o.name === "Varya Stepanova").lightningTalks[0]
.title,
content.talks.find(
o =>
o.title ===
"How to use React, webpack and other buzzwords if there is no need"
).title
);
assert(content.partners.find(o => o.name === "Agent Conf"));
assert.equal(
content.organizers.find(o => o.name === "Toni Ristola").social.twitter,
"toniristola"
);
assert.equal(
content.talks.find(
o =>
o.title ===
"How to use React, webpack and other buzzwords if there is no need"
).type,
schema.enums.LIGHTNING_TALK
);
graphql(
makeExecutableSchema({
typeDefs: schema.typeDefs,
resolvers: {
Query: generateQueries(),
},
}),
"{ speakers { name } }"
)
.then(({ data }) => {
assert.deepEqual(
data.speakers.map(speaker => speaker.name),
Object.values(content.speakers).map(speaker => speaker.name)
);
})
.catch(e => {
throw new Error(e);
});
function generateQueries() {
const ret = {};
Object.keys(content).forEach(k => {
ret[k] = () => Object.values(content[k]);
});
return ret;
}