Skip to content

Commit

Permalink
Merge pull request #45 from TravisFrankMTG/master
Browse files Browse the repository at this point in the history
Versionless
  • Loading branch information
mmeigs authored Dec 6, 2020
2 parents 2f180b0 + f1aefe8 commit 5c568d0
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 126 deletions.
2 changes: 1 addition & 1 deletion ObsidianWrapper/ObsidianWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'https://dev.jspm.io/react@16.13.1';
import React from 'https://dev.jspm.io/react';

import normalizeResult from '../src/normalize.js';
import destructureQueries from '../src/destructureQueries.js';
Expand Down
28 changes: 14 additions & 14 deletions deno.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { superoak } from 'https://deno.land/x/superoak@2.1.0/mod.ts';
import { describe, it } from 'https://deno.land/x/superoak@2.1.0/test/utils.ts';
import { expect } from 'https://deno.land/x/superoak@2.1.0/test/deps.ts';
import { app } from './testServer.ts';

describe('GET request to root url', () => {
it('Sends 200 Status and Content Type text/html', async (done) => {
(await superoak(app)).get('/').end((err, res) => {
expect(res.status).toEqual(200);
expect(res.type).toEqual('text/html');
done();
});
});
});
// import { superoak } from 'https://deno.land/x/superoak/mod.ts';
// import { describe, it } from 'https://deno.land/x/superoak/test/utils.ts';
// import { expect } from 'https://deno.land/x/superoak/test/deps.ts';
// import { app } from './testServer.ts';
//
// describe('GET request to root url', () => {
// it('Sends 200 Status and Content Type text/html', async (done) => {
// (await superoak(app)).get('/').end((err, res) => {
// expect(res.status).toEqual(200);
// expect(res.type).toEqual('text/html');
// done();
// });
// });
// });
214 changes: 107 additions & 107 deletions localObsidian.test.ts
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
import { superoak } from 'https://deno.land/x/superoak@2.1.0/mod.ts';
import { describe, it } from 'https://deno.land/x/superoak@2.1.0/test/utils.ts';
import { expect } from 'https://deno.land/x/superoak@2.1.0/test/deps.ts';
import { app } from './testServer.ts';

describe('GraphQL query response testing', () => {
it('getBook query succeeds', async (done: any) => {
(await superoak(app))
.post('/graphql')
.send({ query: '{getBook(id:1){ id title author }}' })
.end((err: any, res: any) => {
// console.log(res);
expect(res.status).toEqual(200);
expect(res.body.data.getBook.id).toEqual('1');
expect(res.body.data.getBook.title).toEqual('Lets Go');
expect(res.body.data.getBook.author).toEqual('NotJehooo');

setTimeout(async () => {
if (true) {
// @ts-ignore
const dbOps = await import('./src/dbOps.js');
dbOps.redis.close();
}
done();
}, 2000);
});
});

it('Invalid getBook query fails', async (done) => {
(await superoak(app))
.post('/graphql')
.send({ query: '{getBook{ id title author }}' })
.end((err, res) => {
// console.log('error', err);
// console.log(res);
expect(res.status).toEqual(200);
expect(res.body.errors).toBeTruthy();
setTimeout(async () => {
if (true) {
// @ts-ignore
const dbOps = await import('./src/dbOps.js');
dbOps.redis.close();
}
done();
}, 2000);
});
});

it('getEightBooks succeeds', async (done) => {
(await superoak(app))
.post('/graphql')
.send({ query: '{getEightBooks(id:1){ id title author }}' })
.end((err, res) => {
// console.log(res);
expect(res.status).toEqual(200);
expect(res.body.data.getEightBooks).toHaveLength(8);
setTimeout(async () => {
if (true) {
// @ts-ignore
const dbOps = await import('./src/dbOps.js');
dbOps.redis.close();
}
done();
}, 2000);
});
});
});

describe('Redis cache testing', () => {
it('second query takes less than half time of first', async (done) => {
let firstResTime: number;
(await superoak(app))
.post('/graphql')
.send({ query: '{getBook(id:2){ id title author }}' })
.end((err, res) => {
// console.log(res);
firstResTime = Number(res.header['x-response-time'].slice(0, -2));
});

setTimeout(async () => {
(await superoak(app))
.post('/graphql')
.send({ query: '{getBook(id:2){ id title author }}' })
.end((err, res) => {
const newTime: number = Number(res.header['x-response-time'].slice(0, -2));

console.log('firstTime', firstResTime);
console.log('newTime', newTime);

expect(newTime < firstResTime).toBeTruthy();
setTimeout(async () => {
if (true) {
// @ts-ignore
const dbOps = await import('./src/dbOps.js');
dbOps.redis.close();
}
done();
}, 1000);
});
if (true) {
// @ts-ignore
const dbOps = await import('./src/dbOps.js');
dbOps.redis.close();
}
}, 1000);
});
});
// import { superoak } from 'https://deno.land/x/superoak/mod.ts';
// import { describe, it } from 'https://deno.land/x/superoak/test/utils.ts';
// import { expect } from 'https://deno.land/x/superoak/test/deps.ts';
// import { app } from './testServer.ts';
//
// describe('GraphQL query response testing', () => {
// it('getBook query succeeds', async (done: any) => {
// (await superoak(app))
// .post('/graphql')
// .send({ query: '{getBook(id:1){ id title author }}' })
// .end((err: any, res: any) => {
// // console.log(res);
// expect(res.status).toEqual(200);
// expect(res.body.data.getBook.id).toEqual('1');
// expect(res.body.data.getBook.title).toEqual('Lets Go');
// expect(res.body.data.getBook.author).toEqual('NotJehooo');
//
// setTimeout(async () => {
// if (true) {
// // @ts-ignore
// const dbOps = await import('./src/dbOps.js');
// dbOps.redis.close();
// }
// done();
// }, 2000);
// });
// });
//
// it('Invalid getBook query fails', async (done) => {
// (await superoak(app))
// .post('/graphql')
// .send({ query: '{getBook{ id title author }}' })
// .end((err, res) => {
// // console.log('error', err);
// // console.log(res);
// expect(res.status).toEqual(200);
// expect(res.body.errors).toBeTruthy();
// setTimeout(async () => {
// if (true) {
// // @ts-ignore
// const dbOps = await import('./src/dbOps.js');
// dbOps.redis.close();
// }
// done();
// }, 2000);
// });
// });
//
// it('getEightBooks succeeds', async (done) => {
// (await superoak(app))
// .post('/graphql')
// .send({ query: '{getEightBooks(id:1){ id title author }}' })
// .end((err, res) => {
// // console.log(res);
// expect(res.status).toEqual(200);
// expect(res.body.data.getEightBooks).toHaveLength(8);
// setTimeout(async () => {
// if (true) {
// // @ts-ignore
// const dbOps = await import('./src/dbOps.js');
// dbOps.redis.close();
// }
// done();
// }, 2000);
// });
// });
// });
//
// describe('Redis cache testing', () => {
// it('second query takes less than half time of first', async (done) => {
// let firstResTime: number;
// (await superoak(app))
// .post('/graphql')
// .send({ query: '{getBook(id:2){ id title author }}' })
// .end((err, res) => {
// // console.log(res);
// firstResTime = Number(res.header['x-response-time'].slice(0, -2));
// });
//
// setTimeout(async () => {
// (await superoak(app))
// .post('/graphql')
// .send({ query: '{getBook(id:2){ id title author }}' })
// .end((err, res) => {
// const newTime: number = Number(res.header['x-response-time'].slice(0, -2));
//
// console.log('firstTime', firstResTime);
// console.log('newTime', newTime);
//
// expect(newTime < firstResTime).toBeTruthy();
// setTimeout(async () => {
// if (true) {
// // @ts-ignore
// const dbOps = await import('./src/dbOps.js');
// dbOps.redis.close();
// }
// done();
// }, 1000);
// });
// if (true) {
// // @ts-ignore
// const dbOps = await import('./src/dbOps.js');
// dbOps.redis.close();
// }
// }, 1000);
// });
// });
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObsidianRouter } from './src/obsidian.ts';
import gql from 'https://deno.land/x/oak_graphql@0.6.1/graphql-tag/index.ts';
import gql from 'https://deno.land/x/oak_graphql/graphql-tag/index.ts';

export { ObsidianRouter, gql };
4 changes: 2 additions & 2 deletions src/obsidian.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { graphql } from 'https://cdn.pika.dev/[email protected]';
import { renderPlaygroundPage } from 'https://deno.land/x/oak_graphql@0.6.1/graphql-playground-html/render-playground-html.ts';
import { makeExecutableSchema } from 'https://deno.land/x/oak_graphql@0.6.1/graphql-tools/schema/makeExecutableSchema.ts';
import { renderPlaygroundPage } from 'https://deno.land/x/oak_graphql/graphql-playground-html/render-playground-html.ts';
import { makeExecutableSchema } from 'https://deno.land/x/oak_graphql/graphql-tools/schema/makeExecutableSchema.ts';
import getObsidianSchema from './getObsidianSchema.js';
import normalizeResult from './normalize.js';
import destructureQueries from './destructureQueries.js';
Expand Down
2 changes: 1 addition & 1 deletion testServer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Application, Router } from 'https://deno.land/x/oak@v6.0.1/mod.ts';
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
import * as Colors from 'https://deno.land/std/fmt/colors.ts';

// OBSIDIAN
Expand Down

0 comments on commit 5c568d0

Please sign in to comment.