This commit is contained in:
Georgy Berezhnoy 2021-04-11 21:42:32 +03:00
commit 97dd938bfa
2 changed files with 15 additions and 3 deletions

View file

@ -359,18 +359,22 @@ export default class Tools extends Module {
}
if (Array.isArray(tool.enabledBlockTunes)) {
tool.tunes = new ToolsCollection<BlockTune>(
const userTunes = new ToolsCollection<BlockTune>(
tool.enabledBlockTunes.map(name => [name, this.blockTunes.get(name)])
);
tool.tunes = new ToolsCollection<BlockTune>([...userTunes, ...this.blockTunes.internalTools]);
return;
}
if (Array.isArray(this.config.tunes)) {
tool.tunes = new ToolsCollection<BlockTune>(
const userTunes = new ToolsCollection<BlockTune>(
this.config.tunes.map(name => [name, this.blockTunes.get(name)])
);
tool.tunes = new ToolsCollection<BlockTune>([...userTunes, ...this.blockTunes.internalTools]);
return;
}

View file

@ -204,12 +204,20 @@ describe('Tools module', () => {
expect(Array.from(module.blockTools.values()).every(tool => tool.isBlock())).to.be.true;
});
it('Block Tools should contain default tunes', () => {
let tool = module.blockTools.get('blockTool');
expect(tool.tunes.has('deleteTune')).to.be.true;
expect(tool.tunes.has('moveUpTune')).to.be.true;
expect(tool.tunes.has('moveDownTune')).to.be.true;
});
it('Block Tools should contain tunes in correct order', () => {
let tool = module.blockTools.get('blockTool');
expect(tool.tunes.has('blockTune')).to.be.true;
expect(tool.tunes.has('blockTune2')).to.be.true;
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune']);
expect(Array.from(tool.tunes.keys())).to.be.deep.eq(['blockTune2', 'blockTune', 'moveUpTune', 'deleteTune', 'moveDownTune']);
tool = module.blockTools.get('withSuccessfulPrepare');