Skip to content

Commit 5402463

Browse files
committed
Update README
1 parent 0d25203 commit 5402463

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Public analytics as a Node.js microservice, no sysadmin experience required.
44

5-
[![Build Status](https://travis-ci.org/micro-analytics/micro-analytics.svg?branch=master)](https://travis-ci.org/micro-analytics/micro-analytics) [![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/micro-analytics/micro-analytics-cli)
5+
[![Build Status](https://travis-ci.org/micro-analytics/micro-analytics-cli.svg?branch=master)](https://travis-ci.org/micro-analytics/micro-analytics) [![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/micro-analytics/micro-analytics-cli)
66

77

88
A tiny analytics server with ~100 lines of code, easy to run and hack around on. It does one thing, and it does it well: count the views of something and making the views publicly accessible via an API.

writing-adapters.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,33 @@ module.exports = {
3232
}
3333
```
3434

35-
Let's dive into the individual methods:
35+
## Tests
36+
37+
There is pre-written tests for adapters that you can use to make sure you adapter is implemented
38+
correctly. These can be easily used by adding jest and micro-analytics-cli as a dev dependency to your adapter(e.g. `npm install --save-dev micro-analytics-cli jest`). Then create a test file like the one below.
39+
40+
```js
41+
// adapter.test.js
42+
const test = require('micro-analytics-cli/adapter-tests/unit-tests')
43+
44+
test({
45+
name: 'adapter-name',
46+
modulePath: path.resolve(__dirname, './index.js'),
47+
})
48+
```
49+
50+
The option object takes the following properties.
51+
52+
* `name` - The name of the adapter
53+
* `modulePath` - The absolute path to the file you refer to in main in package.json
54+
* `beforeEach` - Will be called in jest beforeEach hook, return a promise if it needs to do something async. We recommend cleaning the database here.
55+
* `afterEach` - Will be called in jest afterEach hook, return a promise if it needs to do something async.
56+
* `beforeAll` - Will be called in jest beforeAll hook, return a promise if it needs to do something async.
57+
* `afterAll` - Will be called in jest afterAll hook, return a promise if it needs to do something async.
58+
59+
Let's dive into the individual methods and what they should do.
60+
61+
## Methods
3662

3763
### `get(key: string, options?: { filter?: object }): Promise`
3864

@@ -184,26 +210,3 @@ subscription.unsubscribe()
184210
```
185211

186212
> **Note:** If your database of choice does not support subscriptions, it is fine not to have `adapter.subscribe` as long as you mention that visibly in your documentation.
187-
188-
## Tests
189-
190-
There is pre-written tests for adapters that you can use to make sure you adapter is implemented
191-
correctly. These can be easily used by adding jest and micro-analytics-cli as a dev dependency to your adapter(e.g. `npm install --save-dev micro-analytics-cli jest`). Then create a test file like the one below.
192-
193-
```js
194-
const test = require('micro-analytics-cli/adapter-tests/unit-tests')
195-
196-
test({
197-
name: 'adapter-name',
198-
modulePath: path.resolve(__dirname, './index.js'),
199-
})
200-
```
201-
202-
The option object takes the following properties.
203-
204-
* `name` - The name of the adapter
205-
* `modulePath` - The absolute path to the file you refer to in main in package.json
206-
* `beforeEach` - Will be called in jest beforeEach hook, return a promise if it needs to do something async. We recommend cleaning the database here.
207-
* `afterEach` - Will be called in jest afterEach hook, return a promise if it needs to do something async.
208-
* `beforeAll` - Will be called in jest beforeAll hook, return a promise if it needs to do something async.
209-
* `afterAll` - Will be called in jest afterAll hook, return a promise if it needs to do something async.

0 commit comments

Comments
 (0)