Files: a683541f27c2757c560090b0fa816b37d947d42f / intermediate / channelV1.test.js
822 bytesRaw
1 | const test = require('tape') |
2 | const Server = require('scuttle-testbot') |
3 | const pull = require('pull-stream') |
4 | |
5 | test('get a count of the number of posts to a channel', t => { |
6 | Server.use(require('./channelV1')) |
7 | const server = Server() |
8 | |
9 | t.plan(1) |
10 | |
11 | pull( |
12 | pull.values(['myco', 'ssb', 'economics', 'monkeys', 'pineapples', null, 'pineapples', undefined]), |
13 | pull.asyncMap(function (channel, cb) { |
14 | // write 5 messages to the database |
15 | server.publish({ type: 'post', channel, text: 'hello world' }, cb) |
16 | }), |
17 | pull.collect((err, msgs) => { |
18 | // use channel plugin to find out how many times each channel has been mentioned |
19 | server.channel.all((err, data) => { |
20 | t.deepEqual({ myco: 1, ssb: 1, economics: 1, monkeys: 1, pineapples: 2 }, data) |
21 | server.close() |
22 | }) |
23 | }) |
24 | ) |
25 | }) |
26 |
Built with git-ssb-web