-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(2051): fix validate function that does not exist (#29)
- Loading branch information
Showing
2 changed files
with
96 additions
and
4 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 |
---|---|---|
|
@@ -512,6 +512,98 @@ describe('index', () => { | |
assert.equal(err.name, 'ValidationError'); | ||
} | ||
}); | ||
|
||
it('is valid config with complete parameters', () => { | ||
configMock = { | ||
email: { | ||
addresses: ['[email protected]', '[email protected]'], | ||
statuses: ['SUCCESS', 'FAILURE'] | ||
} | ||
}; | ||
|
||
const res = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.isUndefined(res.error); | ||
}); | ||
|
||
it('is valid config with empty statuses', () => { | ||
configMock = { | ||
email: { | ||
addresses: ['[email protected]', '[email protected]'], | ||
statuses: [] | ||
} | ||
}; | ||
|
||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.isUndefined(error); | ||
}); | ||
|
||
it('is valid config with addresses', () => { | ||
configMock = { | ||
email: { | ||
addresses: ['[email protected]', '[email protected]'] | ||
} | ||
}; | ||
|
||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.isUndefined(error); | ||
}); | ||
|
||
it('is invalid config with empty parameters', () => { | ||
configMock = {}; | ||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.instanceOf(error, Error); | ||
assert.equal(error.name, 'ValidationError'); | ||
}); | ||
|
||
it('valid config with empty email settings', () => { | ||
configMock = { | ||
email: {} | ||
}; | ||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.isUndefined(error); | ||
}); | ||
|
||
it('valid config without addresses', () => { | ||
configMock = { | ||
email: { | ||
statuses: ['SUCCESS', 'FAILURE'] | ||
} | ||
}; | ||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.isUndefined(error); | ||
}); | ||
|
||
it('invalid config with empty addresses', () => { | ||
configMock = { | ||
email: { | ||
addresses: [], | ||
statuses: ['SUCCESS', 'FAILURE'] | ||
} | ||
}; | ||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.instanceOf(error, Error); | ||
assert.equal(error.name, 'ValidationError'); | ||
}); | ||
|
||
it('invalid unknown status', () => { | ||
configMock = { | ||
email: { | ||
addresses: ['[email protected]'], | ||
statuses: ['DUMMY_STATUS'] | ||
} | ||
}; | ||
const { error } = EmailNotifier.validateConfig(configMock); | ||
|
||
assert.instanceOf(error, Error); | ||
assert.equal(error.name, 'ValidationError'); | ||
}); | ||
}); | ||
|
||
describe('buildData is validated', () => { | ||
|