Files: caa4a4b8f577c0181656d117489972a48ac3b438 / 2_singleuserpublishing.test.js
1058 bytesRaw
1 | const test = require('tape') |
2 | const Server = require('scuttle-testbot') |
3 | const pull = require('pull-stream') |
4 | |
5 | test('publish a message and get it back', t => { |
6 | var server = Server() |
7 | |
8 | t.plan(2) |
9 | |
10 | var content = { |
11 | type: "post", |
12 | text: "hello world" |
13 | } |
14 | |
15 | server.publish(content, (err, msg) => { |
16 | t.equal(msg.value.content.type, 'post') |
17 | t.equal(msg.value.content.text, 'hello world') |
18 | |
19 | // Make sure you close the server or tests will hang |
20 | server.close() |
21 | }) |
22 | }) |
23 | |
24 | test('pull the message and compare with published', t => { |
25 | var server = Server() |
26 | |
27 | t.plan(1) |
28 | |
29 | pull( |
30 | server.createFeedStream({ live: true }), |
31 | pull.filter(msg => msg.sync !== true), // live streams emit { sync: true } when 'up to speed' |
32 | pull.take(1), |
33 | pull.drain(msg => { |
34 | t.deepEqual(msg.value.content, content) |
35 | |
36 | // Make sure you close the server or tests will hang |
37 | server.close() |
38 | }) |
39 | ) |
40 | |
41 | var content = { |
42 | type: "post", |
43 | text: "hello world" |
44 | } |
45 | |
46 | server.publish(content, (err, msg) => { |
47 | // Must provide a callback |
48 | }) |
49 | }) |
50 |
Built with git-ssb-web