Skip to content

Commit 2194cb6

Browse files
committed
Merge branch 'dev' into keelyt/cleanup
2 parents b6c584f + 68838de commit 2194cb6

12 files changed

+155
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package-lock.json
55
.rdb
66
quell-server/package-lock.json
77
quell-server/node_modules
8+
quell-server/coverage
89
quell-client/package-lock.json
910
quell-client/node_modules
1011
quell-extension/node_modules

quell-server/__tests__/helpers/buildFromCache.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const QuellCache = require('../../src/quell.js');
1+
const QuellCache = require('../../src/quell.ts');
22
const schema = require('../../test-config/testSchema');
33

44
const redisPort = 6379;
@@ -15,7 +15,7 @@ xdescribe('server test for buildFromCache', () => {
1515
// inputs: prototype object (which contains args), collection (defaults to an empty array)
1616
// outputs: protoype object with fields that were not found in the cache set to false
1717

18-
beforeAll(() => {
18+
xbeforeAll(() => {
1919
const promise1 = (resolve, reject) => {
2020
resolve(
2121
Quell.writeToCache('country--1', {
@@ -42,12 +42,12 @@ xdescribe('server test for buildFromCache', () => {
4242
return [promise1, promise2, promise3, promise4];
4343
});
4444

45-
afterAll((done) => {
45+
xafterAll((done) => {
4646
Quell.redisCache.flushAll();
4747
done();
4848
});
4949

50-
test('Basic query', async () => {
50+
xtest('Basic query', async () => {
5151
const testProto = {
5252
country: {
5353
id: true,
@@ -85,7 +85,7 @@ xdescribe('server test for buildFromCache', () => {
8585
expect(responseFromCache).toEqual(expectedResponseFromCache);
8686
});
8787

88-
test('Basic query for data not in the cache', async () => {
88+
xtest('Basic query for data not in the cache', async () => {
8989
const testProto = {
9090
book: {
9191
id: true,
@@ -211,7 +211,7 @@ xdescribe('server test for buildFromCache', () => {
211211
expect(responseFromCache).toEqual(expectedResponseFromCache);
212212
});
213213

214-
test('Handles array', async () => {
214+
xtest('Handles array', async () => {
215215
const testProto = {
216216
countries: {
217217
id: true,
@@ -254,7 +254,7 @@ xdescribe('server test for buildFromCache', () => {
254254
expect(responseFromCache).toEqual(expectedResponseFromCache);
255255
});
256256

257-
test('Handles deeply nested queries with an empty cache', async () => {
257+
xtest('Handles deeply nested queries with an empty cache', async () => {
258258
const testProto = {
259259
continents: {
260260
id: true,

quell-server/__tests__/helpers/createQueryObj.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { createQueryObj } = require('../../src/quell');
2+
const { createQueryObj } = require('../../src/helpers/quellHelpers');
33

44
describe('server side tests for createQueryObj.js', () => {
55
afterAll((done) => {

quell-server/__tests__/helpers/createQueryStr.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { createQueryStr } = require('../../src/quell');
2+
const { createQueryStr } = require('../../src/helpers/quellHelpers');
33

44
describe('server side tests for createQueryStr.js', () => {
55
afterAll((done) => {

quell-server/__tests__/helpers/getFieldsMap.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { getFieldsMap } = require('../../src/quell');
2+
const { getFieldsMap } = require('../../src/helpers/quellHelpers');
33
const schema = require('../../test-config/testSchema');
44
const schemaWithoutFields = require('../../test-config/testSchemaWithoutFields');
55

quell-server/__tests__/helpers/getMutationMap.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { getMutationMap } = require('../../src/quell');
2+
const { getMutationMap } = require('../../src/helpers/quellHelpers');
33
const schema = require('../../test-config/testSchema');
44
const schemaWithoutMuts = require('../../test-config/testSchemaWithoutMuts');
55

quell-server/__tests__/helpers/getQueryMap.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { getQueryMap } = require('../../src/quell');
2+
const { getQueryMap } = require('../../src/helpers/quellHelpers');
33
const schema = require('../../test-config/testSchema');
44
const schemaWithoutQueries = require('../../test-config/testSchemaWithoutQueries');
55

quell-server/__tests__/helpers/joinResponses.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { joinResponses } = require('../../src/quell');
2+
const { joinResponses } = require('../../src/helpers/quellHelpers');
33

44
describe('tests for joinResponses on the server side', () => {
55
afterAll((done) => {
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/* eslint-disable no-undef */
2+
const { normalizeForCache2 } = require('../../src/helpers/quellHelpers');
3+
4+
// This test is not fully working. NormalizeForCache needs to be refactored to store
5+
// a normalized version in the cache as well as the evaluated object being used as a
6+
// reference. Test will need to be written to reflect how the normalized response is
7+
// stored. BuildFromCache would also have to be re-written to be able to properly build
8+
// the normalized response.
9+
xdescribe('server side tests for normalizeForCache2', () => {
10+
beforeEach((done) => {
11+
const idCache = {
12+
'6365be1ff176b90f3b81f0e9': {
13+
id: '6365be1ff176b90f3b81f0e9',
14+
name: 'Frank Ocean',
15+
albums: [
16+
{ _ref: '6359930abeb03be432d17785' },
17+
{ _ref: '63599379beb03be432d17786' }
18+
]
19+
},
20+
'6359930abeb03be432d17785': {
21+
id: '6359930abeb03be432d17785',
22+
name: 'Channel Orange'
23+
},
24+
'63599379beb03be432d17786': {
25+
id: '63599379beb03be432d17786',
26+
name: 'Blonde'
27+
}
28+
};
29+
done();
30+
});
31+
afterAll((done) => {
32+
done();
33+
});
34+
test('Correctly returns a normalized version of the query response with proper references for nested objects', () => {
35+
const unNormalizedResponse = {
36+
artist: [
37+
{
38+
id: '6365be1ff176b90f3b81f0e9',
39+
name: 'Frank Ocean',
40+
albums: [
41+
{ id: '6359930abeb03be432d17785', name: 'Channel Orange' },
42+
{ id: '63599379beb03be432d17786', name: 'Blonde' }
43+
]
44+
}
45+
]
46+
};
47+
const map = {
48+
song: 'Song',
49+
album: 'Album',
50+
artist: ['Artist'],
51+
country: 'Country',
52+
city: 'City',
53+
attractions: 'Attractions'
54+
};
55+
expect(normalizeForCache2(unNormalizedResponse, map)).toEqual({
56+
'6365be1ff176b90f3b81f0e9': {
57+
id: '6365be1ff176b90f3b81f0e9',
58+
name: 'Frank Ocean',
59+
albums: [
60+
{ _ref: '6359930abeb03be432d17785' },
61+
{ _ref: '63599379beb03be432d17786' }
62+
]
63+
},
64+
'6359930abeb03be432d17785': {
65+
id: '6359930abeb03be432d17785',
66+
name: 'Channel Orange'
67+
},
68+
'63599379beb03be432d17786': {
69+
id: '63599379beb03be432d17786',
70+
name: 'Blonde'
71+
}
72+
});
73+
});
74+
test('Correctly returns a normalized version of the query response for deeply nested objects', () => {
75+
const unNormalizedResponse = {
76+
country: [
77+
{
78+
id: '6365be1ff176b90f3b81f0e9',
79+
name: 'United States',
80+
cities: [
81+
{
82+
id: '6359930abeb03be432d17785',
83+
name: 'Los Angeles',
84+
attractions: [
85+
{ id: '6359930abeb03be432lasdbf', name: 'Hollywood' }
86+
]
87+
},
88+
{
89+
id: '63599379beb03be432d17786',
90+
name: 'San Francisco',
91+
attractions: [
92+
{
93+
id: '6359930abeb03be432lasdfvzxc',
94+
name: 'Golden Gate Bridge'
95+
}
96+
]
97+
}
98+
]
99+
}
100+
]
101+
};
102+
const map = {
103+
song: 'Song',
104+
album: 'Album',
105+
artist: ['Artist'],
106+
country: 'Country',
107+
city: 'City',
108+
attractions: 'Attractions'
109+
};
110+
expect(normalizeForCache2(unNormalizedResponse, map)).toEqual({
111+
'6365be1ff176b90f3b81f0e9': {
112+
id: '6365be1ff176b90f3b81f0e9',
113+
name: 'United States',
114+
cities: [
115+
{ _ref: '6359930abeb03be432d17785' },
116+
{ _ref: '63599379beb03be432d17786' }
117+
]
118+
},
119+
'6359930abeb03be432d17785': {
120+
id: '6359930abeb03be432d17785',
121+
name: 'Los Angeles',
122+
attractions: [{ _ref: '6359930abeb03be432lasdbf' }]
123+
},
124+
'63599379beb03be432d17786': {
125+
id: '63599379beb03be432d17786',
126+
name: 'San Francisco',
127+
attractions: [{ _ref: '6359930abeb03be432lasdfvzxc' }]
128+
},
129+
'6359930abeb03be432lasdbf': {
130+
id: '6359930abeb03be432lasdbf',
131+
name: 'Hollywood'
132+
},
133+
'6359930abeb03be432lasdfvzxc': {
134+
id: '6359930abeb03be432lasdfvzxc',
135+
name: 'Golden Gate Bridge'
136+
}
137+
});
138+
});
139+
});

quell-server/__tests__/helpers/parseAST.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { parseAST } = require('../../src/quell');
2+
const { parseAST } = require('../../src/helpers/quellHelpers');
33
const { parse } = require('graphql/language/parser');
44

55
describe('server tests for Quell.parseAST.js', () => {

quell-server/__tests__/helpers/updateProtoWithFragment.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { updateProtoWithFragment } = require('../../src/quell');
2+
const { updateProtoWithFragment } = require('../../src/helpers/quellHelpers');
33

44
describe('tests for update prototype with fragments on the server side', () => {
55
afterAll((done) => {

quell-server/src/quell.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
getQueryMap,
1414
getFieldsMap
1515
} from './helpers/quellHelpers';
16-
1716
import type { GraphQLSchema, ExecutionResult, DocumentNode } from 'graphql';
1817
import type {
1918
ConstructorOptions,

0 commit comments

Comments
 (0)