Skip to content

Commit a71c403

Browse files
committed
fix remaining tests
1 parent e850f6b commit a71c403

File tree

5 files changed

+146
-103
lines changed

5 files changed

+146
-103
lines changed

__snapshots__/index.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
exports[`graphqlGun can do the basics 1`] = `
44
Object {
5-
"foo": Object {
5+
"gGcdtb": Object {
66
"bar": "baz",
77
},
88
}
99
`;
1010

1111
exports[`graphqlGun lets you grab the chain at any point 1`] = `
1212
Object {
13-
"foo": Object {
13+
"gGlygtcaap": Object {
1414
"bar": Object {
1515
"_chain": undefined,
1616
"hello": undefined,

index.test.js

+108-78
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,43 @@ const gun = Gun();
77

88
describe("graphqlGun", () => {
99
it("can do the basics", async () => {
10-
gun.get("foo").put({ bar: "baz" });
10+
gun.get("gGcdtb").put({ bar: "baz" });
1111

1212
const { next } = graphqlGun(
13-
gql`{
14-
foo {
13+
gql`
14+
{
15+
gGcdtb {
1516
bar
1617
}
17-
}`,
18+
}
19+
`,
1820
gun
1921
);
2022
await next();
2123
expect(await next()).toMatchSnapshot();
2224
});
2325

2426
it("lets you grab the chain at any point", async () => {
25-
gun.get("foo").put({ bar: "pop" });
27+
gun.get("gGlygtcaap").put({ bar: "pop" });
2628

2729
const results = await graphqlGun(
28-
gql`{
29-
foo {
30-
bar {
31-
_chain
32-
hello
30+
gql`
31+
{
32+
gGlygtcaap {
33+
bar {
34+
_chain
35+
hello
36+
}
3337
}
3438
}
35-
}`,
39+
`,
3640
gun
3741
);
3842

3943
expect(results).toMatchSnapshot();
4044

4145
await new Promise(resolve => {
42-
results.foo.bar._chain.on(
46+
results.gGlygtcaap.bar._chain.on(
4347
(value, key) => {
4448
expect(key).toEqual("bar");
4549
expect(value).toEqual("pop");
@@ -48,69 +52,89 @@ describe("graphqlGun", () => {
4852
{ changed: true }
4953
);
5054

51-
gun.get("foo").get("bar").put({ some: "stuff" });
55+
gun
56+
.get("gGlygtcaap")
57+
.get("bar")
58+
.put({ some: "stuff" });
5259
});
5360
});
5461

5562
it("iterates over sets", async () => {
63+
const chain = gun.get("gGios");
5664
await new Promise(resolve => {
57-
const thing1 = gun.get("thing1");
65+
const thing1 = chain.get("thing1");
5866
thing1.put({ stuff: "b", more: "ok" });
59-
gun.get("things").set(thing1, resolve);
67+
chain.get("things").set(thing1, resolve);
6068
});
6169
await new Promise(resolve => {
62-
const thing2 = gun.get("thing2");
70+
const thing2 = chain.get("thing2");
6371
thing2.put({ stuff: "c", more: "ok" });
64-
gun.get("things").set(thing2, resolve);
72+
chain.get("things").set(thing2, resolve);
6573
});
6674

6775
const { next } = graphqlGun(
68-
gql`{
69-
things(type: Set) {
70-
stuff
76+
gql`
77+
{
78+
gGios {
79+
things(type: Set) {
80+
stuff
81+
}
82+
}
7183
}
72-
}`,
84+
`,
7385
gun
7486
);
7587

7688
await next();
7789

78-
expect(await next()).toEqual({ things: [{ stuff: "b" }, { stuff: "c" }] });
90+
expect(await next()).toEqual({
91+
gGios: { things: [{ stuff: "b" }, { stuff: "c" }] }
92+
});
7993
});
8094

8195
it("lets you subscribe to updates", async () => {
82-
const thing1 = gun.get("thing1");
83-
const thing2 = gun.get("thing2");
96+
const chain = gun.get("gGlystu");
97+
const thing1 = chain.get("thing1");
98+
const thing2 = chain.get("thing2");
8499
thing1.put({ stuff: "b", more: "ok" });
85100
thing2.put({ stuff: "c", more: "ok" });
86-
gun.get("things").set(thing1);
87-
gun.get("things").set(thing2);
101+
chain.get("things").set(thing1);
102+
chain.get("things").set(thing2);
88103

89104
let { next } = graphqlGun(
90-
gql`{
91-
things(type: Set) {
92-
stuff @live
105+
gql`
106+
{
107+
gGlystu {
108+
things(type: Set) {
109+
stuff @live
110+
}
111+
}
93112
}
94-
}`,
113+
`,
95114
gun
96115
);
97116

98-
expect(await next()).toEqual({ things: [{ stuff: "b" }, { stuff: "c" }] });
117+
expect(await next()).toEqual({
118+
gGlystu: { things: [{ stuff: "b" }, { stuff: "c" }] }
119+
});
99120

100-
gun.get("thing1").put({ stuff: "changed" });
121+
chain.get("thing1").put({ stuff: "changed" });
101122

102123
expect(await next()).toEqual({
103-
things: [{ stuff: "changed" }, { stuff: "c" }]
124+
gGlystu: {
125+
things: [{ stuff: "changed" }, { stuff: "c" }]
126+
}
104127
});
105128
});
106129

107130
it("supports mad nesting", async () => {
108-
const thing1 = gun.get("thing1");
109-
const thing2 = gun.get("thing2");
110-
const moreThings1 = gun.get("moreThing1");
111-
const moreThings2 = gun.get("moreThing2");
112-
const moreThings3 = gun.get("moreThing3");
113-
const moreThings4 = gun.get("moreThing4");
131+
const chain = gun.get("Ggsmn");
132+
const thing1 = chain.get("thing1");
133+
const thing2 = chain.get("thing2");
134+
const moreThings1 = chain.get("moreThing1");
135+
const moreThings2 = chain.get("moreThing2");
136+
const moreThings3 = chain.get("moreThing3");
137+
const moreThings4 = chain.get("moreThing4");
114138
moreThings1.put({ otherStuff: "one fish" });
115139
moreThings2.put({ otherStuff: "two fish" });
116140
moreThings3.put({ otherStuff: "red fish" });
@@ -121,19 +145,21 @@ describe("graphqlGun", () => {
121145
thing1.get("moreThings").set(moreThings2);
122146
thing2.get("moreThings").set(moreThings3);
123147
thing2.get("moreThings").set(moreThings4);
124-
gun.get("things").set(thing1);
125-
gun.get("things").set(thing2);
148+
chain.get("things").set(thing1);
149+
chain.get("things").set(thing2);
126150

127151
let { next } = graphqlGun(
128-
gql`{
129-
things(type: Set) {
130-
stuff
131-
moreThings(type: Set) {
132-
otherStuff
152+
gql`
153+
{
154+
things(type: Set) {
155+
stuff
156+
moreThings(type: Set) {
157+
otherStuff
158+
}
133159
}
134160
}
135-
}`,
136-
gun
161+
`,
162+
chain
137163
);
138164

139165
expect(await next()).toEqual({
@@ -151,12 +177,13 @@ describe("graphqlGun", () => {
151177
});
152178

153179
it("supports mad nesting with subscriptions", async () => {
154-
const thing1 = gun.get("thing1");
155-
const thing2 = gun.get("thing2");
156-
const moreThings1 = gun.get("moreThing1");
157-
const moreThings2 = gun.get("moreThing2");
158-
const moreThings3 = gun.get("moreThing3");
159-
const moreThings4 = gun.get("moreThing4");
180+
const chain = gun.get("gGsmnws");
181+
const thing1 = chain.get("thing1");
182+
const thing2 = chain.get("thing2");
183+
const moreThings1 = chain.get("moreThing1");
184+
const moreThings2 = chain.get("moreThing2");
185+
const moreThings3 = chain.get("moreThing3");
186+
const moreThings4 = chain.get("moreThing4");
160187
moreThings1.put({ otherStuff: "one fish" });
161188
moreThings2.put({ otherStuff: "two fish" });
162189
moreThings3.put({ otherStuff: "red fish" });
@@ -167,19 +194,21 @@ describe("graphqlGun", () => {
167194
thing1.get("moreThings").set(moreThings2);
168195
thing2.get("moreThings").set(moreThings3);
169196
thing2.get("moreThings").set(moreThings4);
170-
gun.get("things").set(thing1);
171-
gun.get("things").set(thing2);
197+
chain.get("things").set(thing1);
198+
chain.get("things").set(thing2);
172199

173200
let { next } = graphqlGun(
174-
gql`{
175-
things(type: Set) @live {
176-
stuff
177-
moreThings(type: Set) {
178-
otherStuff
201+
gql`
202+
{
203+
things(type: Set) @live {
204+
stuff
205+
moreThings(type: Set) {
206+
otherStuff
207+
}
179208
}
180209
}
181-
}`,
182-
gun
210+
`,
211+
chain
183212
);
184213

185214
expect(await next()).toEqual({
@@ -195,10 +224,13 @@ describe("graphqlGun", () => {
195224
]
196225
});
197226

198-
const thing3 = gun.get("thing3");
227+
const thing3 = chain.get("thing3");
199228
thing3.put({ stuff: "d", more: "just added" });
200229
thing2.put({ stuff: "cc" });
201-
gun.get("things").set(thing3);
230+
chain.get("things").set(thing3);
231+
const thing4 = chain.get("thing4");
232+
thing4.put({ stuff: "e" });
233+
chain.get("things").set(thing4);
202234

203235
expect(await next()).toEqual({
204236
things: [
@@ -220,36 +252,34 @@ describe("graphqlGun", () => {
220252
}
221253
]
222254
});
223-
224-
const thing4 = gun.get("thing4");
225-
thing4.put({ stuff: "e" });
226-
gun.get("things").set(thing4);
227255
});
228256

229257
it("works with a simple case of two properties and a promise interface", async () => {
230258
const thing = gun.get("thing");
231259
const fish = thing.get("fish");
232-
fish.put({"color": "red", "fins": 2});
260+
fish.put({ color: "red", fins: 2 });
233261

234262
const result = await graphqlGun(
235-
gql`{
236-
thing {
237-
fish {
238-
color
239-
fins
263+
gql`
264+
{
265+
thing {
266+
fish {
267+
color
268+
fins
269+
}
240270
}
241271
}
242-
}`,
272+
`,
243273
gun
244274
);
245275

246276
expect(result).toEqual({
247277
thing: {
248278
fish: {
249-
color: 'red',
279+
color: "red",
250280
fins: 2
251281
}
252282
}
253-
})
283+
});
254284
});
255285
});

react/__snapshots__/index.test.js.snap

+18-12
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ exports[`react createContainer reloads your component when new data comes 1`] =
1010
>
1111
{
1212
"palette": {
13-
"thing": {
14-
"stuff": {
15-
"one": "hello",
16-
"two": "world"
13+
"rcCrycwndc": {
14+
"thing": {
15+
"stuff": {
16+
"one": "hello",
17+
"two": "world"
18+
}
1719
}
1820
}
1921
},
@@ -32,10 +34,12 @@ exports[`react createContainer reloads your component when new data comes 2`] =
3234
>
3335
{
3436
"palette": {
35-
"thing": {
36-
"stuff": {
37-
"one": "hello",
38-
"two": "world"
37+
"rcCrycwndc": {
38+
"thing": {
39+
"stuff": {
40+
"one": "new",
41+
"two": "world"
42+
}
3943
}
4044
}
4145
},
@@ -54,10 +58,12 @@ exports[`react createContainer renders the fragment in the container 1`] = `
5458
>
5559
{
5660
"palette": {
57-
"color": {
58-
"hue": 255,
59-
"saturation": 255,
60-
"value": 255
61+
"rcCrtfitc": {
62+
"color": {
63+
"hue": 255,
64+
"saturation": 255,
65+
"value": 255
66+
}
6167
}
6268
},
6369
"color": "blue"

react/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const graphqlGunUtil = require("../");
2+
const tryGet = require("try-get");
23

34
module.exports = function({ React, gun }) {
45
function createContainer(Component, { fragments }) {

0 commit comments

Comments
 (0)