documents.test.js 932 B

1234567891011121314151617181920212223
  1. const { eq, ok } = require('../../../helpers/assert');
  2. const { makeNetwork, makePeer } = require('../../../helpers/setup');
  3. const BLOB = '[d](&doc00000000000000000000000000000000000000000000000.sha256)';
  4. describe('documents: publish + list', (t) => {
  5. t('A creates document', async () => {
  6. const net = makeNetwork(); const A = makePeer(net); A.setActor();
  7. const r = await A.use('documents').createDocument(BLOB, ['paper'], 'Doc', 'desc');
  8. ok(r.key);
  9. const list = await A.use('documents').listAll('all');
  10. ok(list.length >= 1);
  11. });
  12. t('A casts opinion', async () => {
  13. const net = makeNetwork(); const A = makePeer(net); A.setActor();
  14. const r = await A.use('documents').createDocument(BLOB, [], 'D', '');
  15. await A.use('documents').createOpinion(r.key, 'interesting');
  16. const list = await A.use('documents').listAll('all');
  17. ok(list[0].opinions_inhabitants.includes(A.keypair.id));
  18. });
  19. });