generated from dankeboy36/esp-exception-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for
setConfigOption
(#20)
Added API for updating the config option value. Signed-off-by: dankeboy36 <[email protected]>
- Loading branch information
1 parent
cbbde45
commit 626031e
Showing
4 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import assert from 'node:assert/strict'; | ||
import { FQBN } from '../index'; | ||
|
||
// Sets the configuration option to a specified value. | ||
const fqbn1 = new FQBN('arduino:samd:mkr1000:o1=v1'); | ||
const fqbn2 = fqbn1.setConfigOption('o1', 'v2'); | ||
assert.strictEqual(fqbn2.vendor, 'arduino'); | ||
assert.strictEqual(fqbn2.arch, 'samd'); | ||
assert.strictEqual(fqbn2.boardId, 'mkr1000'); | ||
assert.deepStrictEqual(fqbn2.options, { o1: 'v2' }); | ||
|
||
// FQBNs are immutable. | ||
assert.deepStrictEqual(fqbn1.options, { o1: 'v1' }); | ||
assert.deepStrictEqual(fqbn2.options, { o1: 'v2' }); | ||
|
||
// Always maintains the position of existing configuration option keys while updating the value. | ||
assert.strictEqual( | ||
new FQBN('arduino:samd:mkr1000:o1=v1,o2=v2') | ||
.setConfigOption('o1', 'v2') | ||
.toString(), | ||
'arduino:samd:mkr1000:o1=v2,o2=v2' | ||
); | ||
|
||
// Inserts new configuration values by default (non-strict mode). | ||
assert.strictEqual( | ||
new FQBN('arduino:samd:mkr1000').setConfigOption('o1', 'v2').toString(), | ||
'arduino:samd:mkr1000:o1=v2' | ||
); | ||
|
||
// In strict mode, it throws an error when setting absent configuration option values. | ||
assert.throws(() => | ||
new FQBN('arduino:samd:mkr1000').setConfigOption('o1', 'v2', true) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters