Fix error on invalid regex for /clean
This commit is contained in:
parent
326e67893c
commit
8399eab33f
3 changed files with 69 additions and 2 deletions
53
test/channel/playlist.js
Normal file
53
test/channel/playlist.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const PlaylistModule = require('../../lib/channel/playlist');
|
||||
const assert = require('assert');
|
||||
const Config = require('../../lib/config');
|
||||
|
||||
describe('PlaylistModule', () => {
|
||||
describe('#handleClean', () => {
|
||||
let fakeChannel = {
|
||||
uniqueName: 'testChannel',
|
||||
logger: {
|
||||
log() {
|
||||
|
||||
}
|
||||
},
|
||||
broadcastToRoom() {
|
||||
},
|
||||
broadcastAll() {
|
||||
},
|
||||
modules: {
|
||||
permissions: {
|
||||
canDeleteVideo() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let fakeUser = {
|
||||
getName() {
|
||||
return 'testUser';
|
||||
},
|
||||
socket: {
|
||||
emit() {
|
||||
}
|
||||
}
|
||||
};
|
||||
let playlistModule = new PlaylistModule(fakeChannel);
|
||||
|
||||
it('rejects invalid regexes', () => {
|
||||
let sentError = false;
|
||||
|
||||
fakeUser.socket.emit = (event, payload) => {
|
||||
assert.strictEqual(event, 'errorMsg');
|
||||
assert.deepStrictEqual(payload, {
|
||||
msg: "Invalid target: -i * -m"
|
||||
});
|
||||
sentError = true;
|
||||
};
|
||||
|
||||
playlistModule.handleClean(fakeUser, "/clean -i * -m", {});
|
||||
|
||||
assert(sentError, 'Expected error due to invalid regex');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue