mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
When the CC field is generated in the UI, the email values are joined together with ", " but when they are parsed, we currently split by just ",". This causes an error on the backend and on the frontend. It seems reasonable to update the code to allow whitespace in the input and to split by `\s*,\s` and also to trim leading and trailing whitespace from the CC list. --------- Co-authored-by: Sojan <sojan@pepalo.com>
17 lines
656 B
JavaScript
17 lines
656 B
JavaScript
import { validEmailsByComma } from '../emailHeadHelper';
|
|
|
|
describe('#validEmailsByComma', () => {
|
|
it('returns true when empty string is passed', () => {
|
|
expect(validEmailsByComma('')).toEqual(true);
|
|
});
|
|
it('returns true when valid emails separated by comma is passed', () => {
|
|
expect(validEmailsByComma('ni@njan.com,po@va.da')).toEqual(true);
|
|
});
|
|
it('returns false when one of the email passed is invalid', () => {
|
|
expect(validEmailsByComma('ni@njan.com,pova.da')).toEqual(false);
|
|
});
|
|
it('strips spaces between emails before validating', () => {
|
|
expect(validEmailsByComma('1@test.com , 2@test.com')).toEqual(true);
|
|
});
|
|
});
|