Skip to content

Commit a4e8ee3

Browse files
Add unit tests for validation helpers (#78)
* Add unit tests for validation helpers * Fix things that biome is mad about
1 parent d5c7e0d commit a4e8ee3

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,13 @@
2929
"/yarn.lock"
3030
],
3131
"homepage": "https://github.com/twilio-labs/plugin-token",
32-
"keywords": [
33-
"oclif-plugin"
34-
],
32+
"keywords": ["oclif-plugin"],
3533
"license": "MIT",
3634
"oclif": {
3735
"name": "token",
3836
"commands": "./src/commands",
3937
"bin": "twilio",
40-
"devPlugins": [
41-
"@oclif/plugin-help"
42-
],
38+
"devPlugins": ["@oclif/plugin-help"],
4339
"topics": {
4440
"token": {
4541
"description": "Generate a temporary token for use in test applications"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const chai = require('chai');
2+
const validateSid =
3+
require('../../src/helpers/validation-helpers.js').validateSid;
4+
5+
describe('validateSid', () => {
6+
context('when a chat service SID is valid', () => {
7+
it('returns true', () => {
8+
const result = validateSid('IS', 'IS12345678901234567890123456789012');
9+
chai.expect(result).to.be.true;
10+
});
11+
});
12+
13+
context('when a service SID is invalid', () => {
14+
context('does not start with the correct prefix', () => {
15+
it('returns false', () => {
16+
const result = validateSid('IS', 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
17+
chai.expect(result).to.be.false;
18+
});
19+
});
20+
context('is not 34 characters long', () => {
21+
it('returns false', () => {
22+
const result = validateSid('IS', 'IS1234567890');
23+
chai.expect(result).to.be.false;
24+
});
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)