Skip to content

Commit cab486b

Browse files
Add unit tests for validation helpers
1 parent d5c7e0d commit cab486b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const chai = require('chai');
2+
const sinon = require('sinon');
3+
const Twilio = require('twilio');
4+
5+
const validateSid = require('../../src/helpers/validation-helpers.js').validateSid;
6+
7+
describe('validateSid', () => {
8+
context(
9+
'when a chat service SID is valid',
10+
() => {
11+
it('returns true', () => {
12+
const result = validateSid('IS', 'IS12345678901234567890123456789012');
13+
chai.expect(result).to.be.true;
14+
});
15+
},
16+
);
17+
18+
context(
19+
'when a service SID is invalid', () => {
20+
context('does not start with the correct prefix', () => {
21+
it('returns false', () => {
22+
const result = validateSid('IS', 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
23+
chai.expect(result).to.be.false;
24+
});
25+
})
26+
context('is not 34 characters long', () => {
27+
it('returns false', () => {
28+
const result = validateSid('IS', 'IS1234567890');
29+
chai.expect(result).to.be.false;
30+
});
31+
})
32+
});
33+
});

0 commit comments

Comments
 (0)