|
1 |
| -// const nodeBlog = require('../'); |
2 |
| -// const { authors, auth, users, articles } = require('../'); |
3 |
| -// const { Authors } = require('../controllers'); |
| 1 | +const nodeBlog = require('../'); |
| 2 | +const { authors, auth, users, articles } = require('../'); |
4 | 3 |
|
5 |
| -// const client = process.env.DB_CLIENT_TEST; |
6 |
| -// const host = process.env.DB_HOST_TEST; |
7 |
| -// const user = process.env.DB_USER_TEST; |
8 |
| -// const database = process.env.DB_NAME_TEST; |
9 |
| -// const password = process.env.DB_PASS_TEST; |
10 |
| -// const debug = process.env.KNEX_DEBUG; |
| 4 | +const client = process.env.DB_CLIENT_TEST; |
| 5 | +const host = process.env.DB_HOST_TEST; |
| 6 | +const user = process.env.DB_USER_TEST; |
| 7 | +const database = process.env.DB_NAME_TEST; |
| 8 | +const password = process.env.DB_PASS_TEST; |
| 9 | +const debug = process.env.KNEX_DEBUG === 'true'; |
11 | 10 |
|
12 |
| -// const nodeBlogArguments = { client, host, user, database, password, debug }; |
13 |
| -// const blog = nodeBlog(client, host, user, database, password, debug); |
| 11 | +const nodeBlogArguments = { client, host, user, database, password, debug }; |
| 12 | +const blog = nodeBlog(client, host, user, database, password, debug); |
14 | 13 |
|
15 |
| -// describe('NodeBlog NPM module', () => { |
16 |
| -// test('NodeBlog to create a knex instance', () => { |
17 |
| -// expect(typeof blog).toBe('function'); |
18 |
| -// }); |
19 |
| -// test('Blog authors should work', async () => { |
20 |
| -// expect.assertions(3); |
21 |
| -// expect(typeof await authors.list(blog)).toBe('array'); |
22 |
| -// expect(await authors.list(blog)).toEqual(Authors.list(blog)); |
23 |
| -// expect(typeof await authors.get(blog, 1)).toBe('object'); |
24 |
| -// }); |
25 |
| -// test('Blog users should work', async () => { |
26 |
| -// expect.assertions(2); |
27 |
| -// expect(typeof await users.list(blog)).toBe('array'); |
28 |
| -// expect(typeof await users.get(blog, 1)).toBe('object'); |
29 |
| -// }); |
30 |
| -// test('Blog articles should work', async () => { |
31 |
| -// expect.assertions(2); |
32 |
| -// expect(typeof await articles.list(blog)).toBe('array'); |
33 |
| -// expect(typeof await articles.get(blog, 1)).toBe('object'); |
34 |
| -// }); |
35 |
| -// }); |
| 14 | +describe('NodeBlog NPM module', () => { |
| 15 | + test('NodeBlog to create a knex instance', () => { |
| 16 | + expect(typeof blog).toBe('function'); |
| 17 | + }); |
| 18 | + test('Blog authors should work', async () => { |
| 19 | + const list = await authors.list(blog); |
| 20 | + const getItem = await authors.get(blog, 1); |
| 21 | + expect(typeof list).toBe('object'); |
| 22 | + expect(typeof getItem).toBe('object'); |
| 23 | + }); |
| 24 | + test('Blog users should work', async () => { |
| 25 | + const list = await users.list(blog); |
| 26 | + const getItem = await users.get(blog, 1); |
| 27 | + expect(typeof list).toBe('object'); |
| 28 | + expect(typeof getItem).toBe('object'); |
| 29 | + }); |
| 30 | + test('Blog articles should work', async () => { |
| 31 | + const list = await articles.list(blog); |
| 32 | + const getItem = await articles.get(blog, 1); |
| 33 | + expect(typeof list).toBe('object'); |
| 34 | + expect(typeof getItem).toBe('object'); |
| 35 | + }); |
| 36 | +}); |
0 commit comments