git ssb

0+

mixmix / ssb-testing-guide



Tree: a683541f27c2757c560090b0fa816b37d947d42f

Files: a683541f27c2757c560090b0fa816b37d947d42f / intermediate / channelV2.test.js

1607 bytesRaw
1const test = require('tape')
2const Server = require('scuttle-testbot')
3const pull = require('pull-stream')
4
5// This test is the same except we're using the V2 view
6test('get a count of the number of posts to a channel', t => {
7 Server.use(require('./channelV2'))
8 const server = Server()
9
10 t.plan(1)
11
12 pull(
13 pull.values(['myco', 'ssb', 'economics', 'monkeys', 'pineapples', null, 'pineapples', undefined]),
14 pull.asyncMap(function (channel, cb) {
15 // write 5 messages to the database
16 server.publish({ type: 'post', channel, text: 'hello world' }, cb)
17 }),
18 pull.collect((err, msgs) => {
19 // use channel plugin to find out how many times each channel has been mentioned
20 server.channel.all((err, data) => {
21 t.deepEqual({ myco: 1, ssb: 1, economics: 1, monkeys: 1, pineapples: 2 }, data)
22 server.close()
23 })
24 })
25 )
26})
27
28test('get a count of how many times all channels have been mentioned', t => {
29 Server.use(require('./channelV2'))
30 const server = Server()
31
32 t.plan(1)
33
34 pull(
35 pull.values(['#myco', '#ssb', '#economics', '#monkeys', '#pineapples', null, '#pineapples', undefined]),
36 pull.asyncMap(function (channel, cb) {
37 server.publish({ type: 'post', text: `hello world ${ channel }`, mentions: [{ link: channel }] }, cb)
38 }),
39 pull.collect((err, msgs) => {
40 // use channel plugin to find out how many times each channel has been mentioned
41 server.channel.all((err, data) => {
42 t.deepEqual({ myco: 1, ssb: 1, economics: 1, monkeys: 1, pineapples: 2 }, data)
43 server.close()
44 })
45 })
46 )
47})
48

Built with git-ssb-web