-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated package to now include jest and coverall
- Loading branch information
Andrew Dabrowski
authored and
Andrew Dabrowski
committed
Sep 30, 2017
1 parent
be59953
commit 213fa34
Showing
8 changed files
with
96 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,11 @@ examples | |
.eslintrc.yml | ||
|
||
# Travis | ||
.travis.yml | ||
.travis.yml | ||
|
||
# Coverage | ||
coverage | ||
|
||
# Tests | ||
jest.config.json | ||
tests |
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
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,5 @@ | ||
{ | ||
"collectCoverageFrom": [ | ||
"lib/*.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
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,11 @@ | ||
'use strict'; | ||
|
||
const SqlConnectionFactory = require('../lib/SqlConnectionFactory.js'); | ||
|
||
describe('SqlConnectionFactory tests', () => { | ||
test('create simple connection', () => { | ||
const sqlConnectionFactory = new SqlConnectionFactory(); | ||
const connection = sqlConnectionFactory.createInstance(); | ||
expect(connection).toBeDefined(); | ||
}); | ||
}); |
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,41 @@ | ||
'use strict'; | ||
|
||
const SqlQueryWorker = require('../lib/SqlQueryWorker.js'); | ||
|
||
describe('SqlQueryWorker tests', () => { | ||
test('query failed', () => { | ||
const connection = { | ||
query: jest.fn((query, callback) => callback('error')), | ||
}; | ||
const sqlQueryWorker = new SqlQueryWorker(); | ||
const myQuery = 'SELECT * FROM table'; | ||
|
||
return sqlQueryWorker.queryAsync(connection, myQuery) | ||
.then((result) => { | ||
expect(result).toBe(); | ||
}) | ||
.catch((err) => { | ||
expect(connection.query).toBeCalledWith(myQuery, | ||
expect.anything()); | ||
expect(err).toBe('error'); | ||
}); | ||
}); | ||
|
||
test('query success', () => { | ||
const connection = { | ||
query: jest.fn((query, callback) => callback(undefined, 'success')), | ||
}; | ||
const sqlQueryWorker = new SqlQueryWorker(); | ||
const myQuery = 'SELECT * FROM table'; | ||
|
||
return sqlQueryWorker.queryAsync(connection, myQuery) | ||
.then((result) => { | ||
expect(connection.query).toBeCalledWith(myQuery, | ||
expect.anything()); | ||
expect(result).toBe('success'); | ||
}) | ||
.catch((err) => { | ||
expect(err).toBe(); | ||
}); | ||
}); | ||
}); |