Skip to content

Commit

Permalink
fix(document datasource): handle the correct return type for the AQL …
Browse files Browse the repository at this point in the history
…query
  • Loading branch information
danwkennedy committed Jul 2, 2019
1 parent 7f4b4b1 commit 69204fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion arango-document-datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ArangoDocumentDataSource extends DataSource {
FOR key in ${keys}
RETURN (DOCUMENT(key))._id
`);
const [nodes] = await cursor.all();
const nodes = await cursor.all();

const output = [];
for (const [index, id] of keys.entries()) {
Expand Down
20 changes: 14 additions & 6 deletions arango-document-datasource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('ArangDocumentDataSource', () => {
describe(`exists`, () => {
test(`it returns true if a document exists`, async () => {
const results = ['123'];
const db = createDb(results);
const db = createExistsDb(results);
const datasource = new ArangoDocumentDataSource(db);
datasource.initialize();

Expand All @@ -55,7 +55,7 @@ describe('ArangDocumentDataSource', () => {

test(`it caches the results`, async () => {
const results = ['123'];
const db = createDb(results);
const db = createExistsDb(results);
const datasource = new ArangoDocumentDataSource(db);
datasource.initialize();

Expand All @@ -67,7 +67,7 @@ describe('ArangDocumentDataSource', () => {

test(`it batches the calls`, async () => {
const results = ['123'];
const db = createDb(results);
const db = createExistsDb(results);
const datasource = new ArangoDocumentDataSource(db);
datasource.initialize();

Expand All @@ -80,7 +80,7 @@ describe('ArangDocumentDataSource', () => {
describe(`manyExist`, () => {
test(`it returns a list of document existence`, async () => {
const results = ['123'];
const db = createDb(results);
const db = createExistsDb(results);
const datasource = new ArangoDocumentDataSource(db);
datasource.initialize();

Expand All @@ -92,7 +92,7 @@ describe('ArangDocumentDataSource', () => {

test(`it caches the results`, async () => {
const results = ['123'];
const db = createDb(results);
const db = createExistsDb(results);
const datasource = new ArangoDocumentDataSource(db);
datasource.initialize();

Expand All @@ -104,7 +104,7 @@ describe('ArangDocumentDataSource', () => {

test(`it batches the calls`, async () => {
const results = ['123'];
const db = createDb(results);
const db = createExistsDb(results);
const datasource = new ArangoDocumentDataSource(db);
datasource.initialize();

Expand All @@ -125,3 +125,11 @@ function createDb(queryResults) {
})
};
}

function createExistsDb(queryResults) {
return {
query: jest.fn().mockResolvedValue({
all: () => queryResults
})
};
}

0 comments on commit 69204fb

Please sign in to comment.