test: fix tests and use action

This commit is contained in:
Barış Soner Uşaklı
2024-04-11 16:33:50 -04:00
parent afe597a275
commit acab46e656
3 changed files with 8 additions and 7 deletions

View File

@@ -103,10 +103,10 @@
"nodebb-plugin-ntfy": "1.7.4", "nodebb-plugin-ntfy": "1.7.4",
"nodebb-plugin-spam-be-gone": "2.2.1", "nodebb-plugin-spam-be-gone": "2.2.1",
"nodebb-rewards-essentials": "1.0.0", "nodebb-rewards-essentials": "1.0.0",
"nodebb-theme-harmony": "1.2.47", "nodebb-theme-harmony": "1.2.48",
"nodebb-theme-lavender": "7.1.8", "nodebb-theme-lavender": "7.1.8",
"nodebb-theme-peace": "2.2.4", "nodebb-theme-peace": "2.2.4",
"nodebb-theme-persona": "13.3.13", "nodebb-theme-persona": "13.3.14",
"nodebb-widget-essentials": "7.0.15", "nodebb-widget-essentials": "7.0.15",
"nodemailer": "6.9.11", "nodemailer": "6.9.11",
"nprogress": "0.2.0", "nprogress": "0.2.0",

View File

@@ -56,8 +56,8 @@ define('forum/account/header', [
components.get('account/delete-content').on('click', () => AccountsDelete.content(ajaxify.data.theirid)); components.get('account/delete-content').on('click', () => AccountsDelete.content(ajaxify.data.theirid));
components.get('account/delete-all').on('click', () => AccountsDelete.purge(ajaxify.data.theirid)); components.get('account/delete-all').on('click', () => AccountsDelete.purge(ajaxify.data.theirid));
components.get('account/flag').on('click', flagAccount); components.get('account/flag').on('click', flagAccount);
components.get('account/block').on('click', toggleBlockAccount); components.get('account/block').on('click', () => toggleBlockAccount('block'));
components.get('account/unblock').on('click', toggleBlockAccount); components.get('account/unblock').on('click', () => toggleBlockAccount('unblock'));
}; };
function selectActivePill() { function selectActivePill() {
@@ -129,10 +129,11 @@ define('forum/account/header', [
}); });
} }
function toggleBlockAccount() { function toggleBlockAccount(action) {
socket.emit('user.toggleBlock', { socket.emit('user.toggleBlock', {
blockeeUid: ajaxify.data.uid, blockeeUid: ajaxify.data.uid,
blockerUid: app.user.uid, blockerUid: app.user.uid,
action,
}, function (err, blocked) { }, function (err, blocked) {
if (err) { if (err) {
return alerts.error(err); return alerts.error(err);

View File

@@ -2457,7 +2457,7 @@ describe('User', () => {
describe('.toggle()', () => { describe('.toggle()', () => {
it('should toggle block', (done) => { it('should toggle block', (done) => {
socketUser.toggleBlock({ uid: 1 }, { blockerUid: 1, blockeeUid: blockeeUid }, (err) => { socketUser.toggleBlock({ uid: 1 }, { blockerUid: 1, blockeeUid: blockeeUid, action: 'block' }, (err) => {
assert.ifError(err); assert.ifError(err);
User.blocks.is(blockeeUid, 1, (err, blocked) => { User.blocks.is(blockeeUid, 1, (err, blocked) => {
assert.ifError(err); assert.ifError(err);
@@ -2468,7 +2468,7 @@ describe('User', () => {
}); });
it('should toggle block', (done) => { it('should toggle block', (done) => {
socketUser.toggleBlock({ uid: 1 }, { blockerUid: 1, blockeeUid: blockeeUid }, (err) => { socketUser.toggleBlock({ uid: 1 }, { blockerUid: 1, blockeeUid: blockeeUid, action: 'unblock' }, (err) => {
assert.ifError(err); assert.ifError(err);
User.blocks.is(blockeeUid, 1, (err, blocked) => { User.blocks.is(blockeeUid, 1, (err, blocked) => {
assert.ifError(err); assert.ifError(err);