From 45d755b6ae33d5582f32f54a39c5bb0914670ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 6 Dec 2021 21:58:56 -0500 Subject: [PATCH] breaking: remove socket.emit('categories.getCategory') --- src/socket.io/categories.js | 8 -------- test/categories.js | 13 +++++-------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/socket.io/categories.js b/src/socket.io/categories.js index 9ccd7c0e0d..ad72658f70 100644 --- a/src/socket.io/categories.js +++ b/src/socket.io/categories.js @@ -4,8 +4,6 @@ const categories = require('../categories'); const privileges = require('../privileges'); const user = require('../user'); const topics = require('../topics'); -const api = require('../api'); -const sockets = require('.'); const SocketCategories = module.exports; @@ -149,12 +147,6 @@ SocketCategories.isModerator = async function (socket, cid) { return await user.isModerator(socket.uid, cid); }; -SocketCategories.getCategory = async function (socket, cid) { - sockets.warnDeprecated(socket, 'GET /api/v3/categories/:cid'); - return await api.categories.get(socket, { cid }); - // return await apiController.getCategoryData(cid, socket.uid); -}; - SocketCategories.loadMoreSubCategories = async function (socket, data) { if (!data || !data.cid || !(parseInt(data.start, 10) > 0)) { throw new Error('[[error:invalid-data]]'); diff --git a/test/categories.js b/test/categories.js index e7bca1a40c..04633da7c9 100644 --- a/test/categories.js +++ b/test/categories.js @@ -200,9 +200,9 @@ describe('Categories', () => { }); }); - describe('socket methods', () => { + describe('api/socket methods', () => { const socketCategories = require('../src/socket.io/categories'); - + const apiCategories = require('../src/api/categories'); before(async () => { await Topics.post({ uid: posterUid, @@ -339,12 +339,9 @@ describe('Categories', () => { }); }); - it('should get category data', (done) => { - socketCategories.getCategory({ uid: posterUid }, categoryObj.cid, (err, data) => { - assert.ifError(err); - assert.equal(categoryObj.cid, data.cid); - done(); - }); + it('should get category data', async () => { + const data = await apiCategories.get({ uid: posterUid }, { cid: categoryObj.cid }); + assert.equal(categoryObj.cid, data.cid); }); });