Skip to content

Commit

Permalink
breaking: remove setTopicSort/setCategorySort
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Nov 23, 2021
1 parent 7aa8588 commit 6dcdf1d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/socket.io/user.js
Expand Up @@ -136,24 +136,6 @@ SocketUser.saveSettings = async function (socket, data) {
return settings;
};

SocketUser.setTopicSort = async function (socket, sort) {
sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/settings');
await api.users.updateSetting(socket, {
uid: socket.uid,
setting: 'topicPostSort',
value: sort,
});
};

SocketUser.setCategorySort = async function (socket, sort) {
sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/settings');
await api.users.updateSetting(socket, {
uid: socket.uid,
setting: 'categoryTopicSort',
value: sort,
});
};

SocketUser.getUnreadCount = async function (socket) {
if (!socket.uid) {
return 0;
Expand Down
66 changes: 66 additions & 0 deletions test/user.js
Expand Up @@ -1927,6 +1927,72 @@ describe('User', () => {
done();
});
});

it('should get unread count 0 for guest', async () => {
const count = await socketUser.getUnreadCount({ uid: 0 });
assert.strictEqual(count, 0);
});

it('should get unread count for user', async () => {
const count = await socketUser.getUnreadCount({ uid: testUid });
assert.strictEqual(count, 2);
});

it('should get unread chat count 0 for guest', async () => {
const count = await socketUser.getUnreadChatCount({ uid: 0 });
assert.strictEqual(count, 0);
});

it('should get unread chat count for user', async () => {
const count = await socketUser.getUnreadChatCount({ uid: testUid });
assert.strictEqual(count, 0);
});

it('should get unread counts 0 for guest', async () => {
const counts = await socketUser.getUnreadCounts({ uid: 0 });
assert.deepStrictEqual(counts, {});
});

it('should get unread counts for user', async () => {
const counts = await socketUser.getUnreadCounts({ uid: testUid });
assert.deepStrictEqual(counts, {
unreadChatCount: 0,
unreadCounts: {
'': 2,
new: 2,
unreplied: 2,
watched: 0,
},
unreadNewTopicCount: 2,
unreadNotificationCount: 0,
unreadTopicCount: 2,
unreadUnrepliedTopicCount: 2,
unreadWatchedTopicCount: 0,
});
});

it('should get user data by uid', async () => {
const userData = await socketUser.getUserByUID({ uid: testUid }, testUid);
assert.strictEqual(userData.uid, testUid);
});

it('should get user data by username', async () => {
const userData = await socketUser.getUserByUsername({ uid: testUid }, 'John Smith');
assert.strictEqual(userData.uid, testUid);
});

it('should get user data by email', async () => {
const userData = await socketUser.getUserByEmail({ uid: testUid }, 'john@example.com');
assert.strictEqual(userData.uid, testUid);
});

it('should check/consent gdpr status', async () => {
const consent = await socketUser.gdpr.check({ uid: testUid }, { uid: testUid });
assert(!consent);
await socketUser.gdpr.consent({ uid: testUid });
const consentAfter = await socketUser.gdpr.check({ uid: testUid }, { uid: testUid });
assert(consentAfter);
});
});

describe('approval queue', () => {
Expand Down

0 comments on commit 6dcdf1d

Please sign in to comment.