Remove playlist items with their group
This commit is contained in:
1 parent
40f0892262
commit
64aeb1b47e
3 files changed
+30
-16
No files matched your search
@@ -105,6 +105,34 @@ test('playlist group colours differ, survive reorder, and clear on ungrouped sli
|
||||
assert.equal(firstMember.style['--playlist-group-bg'], undefined);
|
||||
});
|
||||
|
||||
test('removing a playlist group removes all of its member rows', () => {
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'src', 'web', 'public', 'js', 'playlists', 'playlist-schedule.js'), 'utf8');
|
||||
const functionSource = source.match(/function removePlaylistGroup\(header\) \{[\s\S]*?\n \}/)[0];
|
||||
const removedRows = [];
|
||||
let removedHeader = false;
|
||||
let refreshedOrder = false;
|
||||
const rows = [0, 1, 2].map((index) => ({ remove() { removedRows.push(index); } }));
|
||||
const header = {
|
||||
getAttribute(name) { return name === 'data-group-key' ? 'group-1' : null; },
|
||||
remove() { removedHeader = true; }
|
||||
};
|
||||
const removeGroup = require('node:vm').runInNewContext('(' + functionSource + ')', {
|
||||
getGroupRows(groupKey) {
|
||||
assert.equal(groupKey, 'group-1');
|
||||
return rows;
|
||||
},
|
||||
updateRowOrder(refresh) {
|
||||
refreshedOrder = refresh;
|
||||
}
|
||||
});
|
||||
|
||||
removeGroup(header);
|
||||
|
||||
assert.deepEqual(removedRows, [0, 1, 2]);
|
||||
assert.equal(removedHeader, true);
|
||||
assert.equal(refreshedOrder, true);
|
||||
});
|
||||
|
||||
test('empty playlist groups keep a drop area until a member is added', () => {
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'src', 'web', 'public', 'js', 'playlists', 'playlist-schedule.js'), 'utf8');
|
||||
const functionSource = source.match(/function updatePlaylistGroupEmptyRows\(\) \{[\s\S]*?\n \}/)[0];
|
||||
|
||||
Reference in new issue
Block a user