-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from TravisFrankMTG/master
Versionless
- Loading branch information
Showing
6 changed files
with
126 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
// }); | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters