Skip to content

Commit 9835c94

Browse files
committed
Add tests
1 parent e662139 commit 9835c94

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
typings

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ pg.query(query);
4646

4747
// or using lodash
4848
pg.query(_.assign(SQL`SELECT author FROM books WHERE name = ${book}`, {name: 'my_query'}))
49-
```
49+
```
50+
51+
# Contributing
52+
- Tests are written using [mocha](https://www.npmjs.com/package/mocha) (BDD style) and [chai](https://www.npmjs.com/package/chai) (expect style)

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
"strings"
2222
],
2323
"author": "Felix Becker",
24-
"license": "ISC"
24+
"license": "ISC",
25+
"devDependencies": {
26+
"chai": "^3.3.0"
27+
}
2528
}

test/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* global describe, it */
2+
'use strict'
3+
let expect = require('chai').expect
4+
let SQL = require('..')
5+
6+
describe('SQL', function () {
7+
it('should work with a simple query', function () {
8+
expect(SQL`SELECT * FROM table`).to.deep.equal({
9+
sql: 'SELECT * FROM table',
10+
text: 'SELECT * FROM table',
11+
values: []
12+
})
13+
})
14+
it('should work with a query with values', function () {
15+
let value = 1234
16+
expect(SQL`SELECT * FROM table WHERE column = ${value}`).to.deep.equal({
17+
sql: 'SELECT * FROM table WHERE column = ?',
18+
text: 'SELECT * FROM table WHERE column = $1',
19+
values: [value]
20+
})
21+
})
22+
})

tsd.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "v4",
3+
"repo": "borisyankov/DefinitelyTyped",
4+
"ref": "master",
5+
"path": "typings",
6+
"bundle": "typings/tsd.d.ts",
7+
"installed": {
8+
"assertion-error/assertion-error.d.ts": {
9+
"commit": "d0adccc436197cc7c3559322721e9df86b892bd6"
10+
},
11+
"mocha/mocha.d.ts": {
12+
"commit": "d0adccc436197cc7c3559322721e9df86b892bd6"
13+
},
14+
"chai/chai.d.ts": {
15+
"commit": "d0adccc436197cc7c3559322721e9df86b892bd6"
16+
},
17+
"node/node.d.ts": {
18+
"commit": "d0adccc436197cc7c3559322721e9df86b892bd6"
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)