Skip to content

Commit

Permalink
Fix #1640
Browse files Browse the repository at this point in the history
  • Loading branch information
gohabereg committed Apr 11, 2021
1 parent 32ac52a commit 97dd938
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/modules/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 9 additions & 1 deletion test/cypress/tests/modules/Tools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 97dd938

Please sign in to comment.