-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(coverage): increase to 100% lines in table
- Loading branch information
1 parent
6f19e1a
commit d87e56d
Showing
4 changed files
with
83 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* global describe, it, before */ | ||
process.env.NODE_ENV = 'test'; | ||
|
||
// Require the dev-dependencies | ||
const { assert } = require('chai'); | ||
const knex = require('../../../../knex'); | ||
const Coffee = require('../../../../models/coffee-example'); | ||
|
||
|
||
// Our parent block | ||
describe('TABLE GATEWAY: countGroupBy', () => { // eslint-disable-line | ||
before(async () => { | ||
await knex.seed.run(); | ||
}); | ||
|
||
it('happy path', async () => { | ||
const results = await Coffee.countGroupBy('price', { name: 'expensive' }); | ||
const expected = [ | ||
{ price: 110, count: 1 }, | ||
]; | ||
assert.deepEqual(results, expected); | ||
}); | ||
|
||
it('options is defined', async () => { | ||
const results = await Coffee.countGroupBy('price', {}, { orderBy: ['price', 'desc'] }); | ||
const expected = [ | ||
{ price: null, count: 1 }, | ||
{ price: 110, count: 1 }, | ||
{ price: 100, count: 2 }, | ||
]; | ||
assert.deepEqual(results, expected); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* global describe, it, before */ | ||
process.env.NODE_ENV = 'test'; | ||
|
||
// Require the dev-dependencies | ||
const { assert } = require('chai'); | ||
const knex = require('../../../../knex'); | ||
const Coffee = require('../../../../models/coffee-example'); | ||
|
||
|
||
// Our parent block | ||
describe('TABLE GATEWAY: countIn', () => { // eslint-disable-line | ||
before(async () => { | ||
await knex.seed.run(); | ||
}); | ||
|
||
it('validOptions is not array', async () => { | ||
const results = await Coffee.countIn('price', 110); | ||
assert.equal(results, '1'); | ||
}); | ||
|
||
it('validOptions is array', async () => { | ||
const results = await Coffee.countIn('price', [110, 100]); | ||
assert.equal(results, '3'); | ||
}); | ||
|
||
it('hasQuery', async () => { | ||
const results = await Coffee.countIn('price', [110, 100], { name: 'expensive' }); | ||
assert.equal(results, '1'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* global describe, it */ | ||
process.env.NODE_ENV = 'test'; | ||
|
||
// Require the dev-dependencies | ||
const { assert } = require('chai'); | ||
const Coffee = require('../../../models/coffee-example'); | ||
|
||
|
||
// Our parent block | ||
describe('TABLE GATEWAY: countGroupBy', () => { // eslint-disable-line | ||
|
||
it('happy path', async () => { | ||
assert.equal(Coffee.toString(), 'coffee'); | ||
}); | ||
|
||
|
||
}); |