Node.js based forum software built for the modern web
test: group actor assertion tests
Julian Lamca9a5b6dfba0
diff --git a/test/activitypub/actors.js b/test/activitypub/actors.jsindex 5acf5bd924..7cc8cb418d 100644--- a/test/activitypub/actors.js+++ b/test/activitypub/actors.js@@ -13,6 +13,8 @@ const utils = require('../../src/utils');const request = require('../../src/request');const slugify = require('../../src/slugify');+const helpers = require('./helpers');+describe('Actor asserton', () => {describe('happy path', () => {let uid;@@ -90,6 +92,38 @@ describe('Actor asserton', () => {});});+describe.only('Group assertion', () => {+ let actorUri;++ before(async () => {+ const { id, actor } = helpers.mocks.group();+ actorUri = id;+ activitypub._cache.set(`0;${id}`, actor);+ });++ it('should assert a uri identifying as "Group" into a remote category', async () => {+ const assertion = await activitypub.actors.assertGroup([actorUri]);++ assert(assertion, Array.isArray(assertion));+ assert.strictEqual(assertion.length, 1);++ const category = assertion.pop();+ assert.strictEqual(category.cid, actorUri);+ });++ it('should be considered existing when checked', async () => {+ const exists = await categories.exists(actorUri);++ assert(exists);+ });++ it('should return category data when getter methods are called', async () => {+ const category = await categories.getCategoryData(actorUri);+ assert(category);+ assert.strictEqual(category.cid, actorUri);+ });+});+describe('Controllers', () => {describe('User Actor endpoint', () => {let uid;diff --git a/test/activitypub/feps.js b/test/activitypub/feps.jsindex cec4fbdb11..2df2b99587 100644--- a/test/activitypub/feps.js+++ b/test/activitypub/feps.js@@ -37,7 +37,7 @@ describe('FEPs', () => {await groups.join('administrators', adminUid);uid = await user.create({ username: utils.generateUUID() });- const { id: followerId, actor } = helpers.mocks.actor();+ const { id: followerId, actor } = helpers.mocks.person();activitypub._cache.set(`0;${followerId}`, actor);user.setCategoryWatchState(followerId, [cid], categories.watchStates.tracking);diff --git a/test/activitypub/helpers.js b/test/activitypub/helpers.jsindex 9df1222144..6873dc0340 100644--- a/test/activitypub/helpers.js+++ b/test/activitypub/helpers.js@@ -8,7 +8,7 @@ const Helpers = module.exports;Helpers.mocks = {};-Helpers.mocks.actor = () => {+Helpers.mocks.person = () => {const baseUrl = 'https://example.org';const uuid = utils.generateUUID();const id = `${baseUrl}/${uuid}`;@@ -37,6 +37,13 @@ Helpers.mocks.actor = () => {return { id, actor };};+Helpers.mocks.group = () => {+ const { id, actor } = Helpers.mocks.person();+ actor.type = 'Group';++ return { id, actor };+};+Helpers.mocks.note = (override = {}) => {const baseUrl = 'https://example.org';const uuid = utils.generateUUID();