git ssb

0+

mixmix / scuttle-gathering



Tree: fa119a00e0a13307d66a09f8c482ae107ba31bdb

Files: fa119a00e0a13307d66a09f8c482ae107ba31bdb / update / async / publish.test.js

1630 bytesRaw
1const { group } = require('tape-plus')
2const Scuttle = require('../../')
3const Server = require('../../lib/testbot')
4const getBacklinks = require('../../lib/get-backlinks')
5
6group('update.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('populates branch correctly', (t, done) => {
19 const opts = {
20 title: 'ziva\'s birthday',
21 startDateTime: {
22 epoch: Date.now() + 5000,
23 tz: 'Pacific/ Auckland'
24 }
25 }
26
27 // publish Gathering and initialUpdate
28 scuttle.gathering.async.publish(opts, (err, gathering) => {
29 if (err) console.error(err)
30
31 getBacklinks(server)(gathering, (err, backlinks) => {
32 if (err) console.error(err)
33
34 const [ initialUpdate ] = backlinks
35 t.equal(initialUpdate.value.content.branch, gathering.key, 'initial update has backlink of gathering')
36
37 const opts = {
38 title: 'Ziva\'s Birtdhay',
39 location: 'our place in Mirimar'
40 }
41 // publish secondUpdate
42 scuttle.update.async.publish(gathering, opts, (err, data) => {
43 if (err) console.error(err)
44 console.error('test err')
45
46 getBacklinks(server)(gathering, (err, backlinks) => {
47 if (err) console.error(err)
48
49 const [ initialUpdate, secondUpdate ] = backlinks
50 t.deepEqual(secondUpdate.value.content.branch, [initialUpdate.key], 'second update has backlink of initial update')
51
52 done()
53 })
54 })
55 })
56 })
57 })
58})
59

Built with git-ssb-web