Skip to content

Commit 840548e

Browse files
authored
Merge pull request #3 from micro-analytics/tests
Add tests with unit testsuite from micro-analytics-cli
2 parents dfc94f6 + cdcf29f commit 840548e

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist.js
33
npm-debug.log
4+
views.db

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- node
4+
- 7
5+
- 6
6+
matrix:
7+
allow_failures:
8+
- node_js: 6
9+
script: npm run test
10+
cache: yarn

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Store your micro-analytics data in flat-file-db!",
55
"main": "dist.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1",
7+
"test": "jest",
88
"build": "async-to-gen index.js --out-file dist.js",
99
"prepublish": "npm run build"
1010
},
@@ -33,6 +33,8 @@
3333
"micro-analytics-cli": "^1.2.0"
3434
},
3535
"devDependencies": {
36-
"async-to-gen": "^1.3.0"
36+
"async-to-gen": "^1.3.0",
37+
"jest": "^19.0.2",
38+
"micro-analytics-cli": "1.2.0-11"
3739
}
3840
}

test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const path = require('path')
2+
const flatfile = require('flat-file-db')
3+
const promisify = require('then-flat-file-db')
4+
const test = require('micro-analytics-cli/adapter-tests/unit-tests')
5+
6+
const db = promisify(flatfile.sync(process.env.DB_NAME || 'views.db'))
7+
8+
9+
test({
10+
name: 'flat-file-db',
11+
modulePath: path.resolve(__dirname, './index.js'),
12+
beforeEach: () => {
13+
return db.clear();
14+
}
15+
})

0 commit comments

Comments
 (0)