test(cli)!: Add test for multiple config options

Note: there was a breaking change that we forgot to document. Ww write the breaking change here for it to be picked up in the future 3.0 release,
even though it was introduced in commit 3871765

BREAKING CHANGE: the CLI no longer accepts "extra options". Instead you should pass the `-c` flag. To update:

before:
```
showdown makehtml -i foo.md -o bar.html --strikethrough --emoji
```

after:
```
showdown makehtml -i foo.md -o bar.html -c strikethrough -c emoji
```

Closes #916
This commit is contained in:
Estevão Soares dos Santos 2022-04-21 01:17:34 +01:00
parent 8b488825ac
commit 914129f5dc
2 changed files with 11 additions and 1 deletions

View File

@ -52,7 +52,7 @@ program.command('makehtml')
.option('-a, --append', 'Append data to output instead of overwriting. Ignored if writing to stdout', false) .option('-a, --append', 'Append data to output instead of overwriting. Ignored if writing to stdout', false)
.option('-e, --extensions <extensions...>', 'Load the specified extensions. Should be valid paths to node compatible extensions') .option('-e, --extensions <extensions...>', 'Load the specified extensions. Should be valid paths to node compatible extensions')
.option('-p, --flavor <flavor>', 'Run with a predetermined flavor of options. Default is vanilla', 'vanilla') .option('-p, --flavor <flavor>', 'Run with a predetermined flavor of options. Default is vanilla', 'vanilla')
.option('-c, --config <config...>', 'Enables showdown makehtml parser config options. Overrides flavor') .option('-c, --config <config...>', 'Enables showdown makehtml parser config options (example: strikethrough). Overrides flavor')
.option('--config-help', 'Shows configuration options for showdown parser') .option('--config-help', 'Shows configuration options for showdown parser')
.action(makehtmlCommand); .action(makehtmlCommand);

View File

@ -128,6 +128,16 @@ describe('showdown cli', function () {
proc.stdout.should.equal('<p>this is a 😄</p>'); proc.stdout.should.equal('<p>this is a 😄</p>');
}); });
it('should enable 2 showdown options (emoji and strikethrough)', function () {
var proc = spawnCLI('makehtml', ['-c', 'emoji', '-c', 'strikethrough'], {
input: 'this is ~~not~~ a :smile:',
encoding: 'utf-8'
});
proc.status.should.equal(0);
proc.stderr.should.contain('Enabling option emoji');
proc.stdout.should.equal('<p>this is <del>not</del> a 😄</p>');
});
it('should ignore unrecognized options', function () { it('should ignore unrecognized options', function () {
var proc = spawnCLI('makehtml', ['-c', 'foobar'], { var proc = spawnCLI('makehtml', ['-c', 'foobar'], {
input: 'foo', input: 'foo',