Improve script/category name validation
- Use better error messages with more context. - Unify their validation logic and share tests. - Validate also type of the name. - Refactor node (Script/Category) parser tests for easier future changes and cleaner test code (using `TestBuilder` to do dirty work in unified way). - Add more tests. Custom `Error` properties are compared manually due to `chai` not supporting deep equality checks (chaijs/chai#1065, chaijs/chai#1405).
This commit is contained in:
@@ -24,12 +24,10 @@ describe('Script', () => {
|
||||
describe('throws when missing', () => {
|
||||
itEachAbsentObjectValue((absentValue) => {
|
||||
// arrange
|
||||
const name = 'script-name';
|
||||
const expectedError = `missing code (script: ${name})`;
|
||||
const expectedError = 'missing code';
|
||||
const code: IScriptCode = absentValue;
|
||||
// act
|
||||
const construct = () => new ScriptBuilder()
|
||||
.withName(name)
|
||||
.withCode(code)
|
||||
.build();
|
||||
// assert
|
||||
|
||||
Reference in New Issue
Block a user