Files: 9e830272505d9e2ac2dae4bf6e6b34e6e05ab905 / gathering / async / publish.test.js
1996 bytesRaw
1 | const { group } = require('tape-plus') |
2 | const Scuttle = require('../../') |
3 | const Server = require('../../lib/testbot') |
4 | const getBacklinks = require('../../lib/get-backlinks') |
5 | |
6 | group('gathering.async.publish', test => { |
7 | var server |
8 | var scuttle |
9 | |
10 | test.beforeEach(t => { |
11 | server = Server() |
12 | scuttle = Scuttle(server) |
13 | }) |
14 | test.afterEach(t => { |
15 | server.close() |
16 | }) |
17 | |
18 | test('happy path', (t, done) => { |
19 | const opts = { |
20 | title: 'ziva\'s birthday party', |
21 | description: 'it\'s been a hell of a year. come join us to celebrate the start of this gorgeous human', |
22 | startDateTime: { |
23 | epoch: Date.now() + 5000 |
24 | } |
25 | } |
26 | |
27 | scuttle.gathering.async.publish(opts, (err, gathering) => { |
28 | t.false(err, 'no error') |
29 | t.equal(gathering.value.content.type, 'gathering', 'calls back with gathering msg') |
30 | |
31 | getBacklinks(server)(gathering, (err, backlinks) => { |
32 | if (err) console.log(err) |
33 | |
34 | t.true(backlinks.length === 1, 'there is only one backlink') |
35 | t.equal(backlinks[0].value.content.type, 'about', 'the backlink is an about message') |
36 | done() |
37 | }) |
38 | }) |
39 | }) |
40 | |
41 | test('missing title', (t, done) => { |
42 | const opts = { |
43 | description: 'it\'s been a hell of a year. come join us to celebrate the start of this gorgeous human', |
44 | startDateTime: { |
45 | epoch: Date.now() + 5000 |
46 | } |
47 | } |
48 | |
49 | scuttle.gathering.async.publish(opts, (err, data) => { |
50 | t.true(err, 'complains about lack of title') |
51 | // console.log(err) |
52 | t.false(data, 'no publish') |
53 | |
54 | done() |
55 | }) |
56 | }) |
57 | |
58 | test('missing startDateTime', (t, done) => { |
59 | const opts = { |
60 | title: 'ziva\'s birthday party', |
61 | description: 'it\'s been a hell of a year. come join us to celebrate the start of this gorgeous human' |
62 | } |
63 | |
64 | scuttle.gathering.async.publish(opts, (err, data) => { |
65 | t.true(err, 'complains about lack of startDateTime') |
66 | // console.log(err) |
67 | t.false(data, 'no publish') |
68 | |
69 | done() |
70 | }) |
71 | }) |
72 | }) |
73 |
Built with git-ssb-web