From cab486b970e8eeb4225c534df88843b286524a1e Mon Sep 17 00:00:00 2001 From: Mica Swyers Date: Tue, 10 Jun 2025 15:10:20 +0100 Subject: [PATCH 1/2] Add unit tests for validation helpers --- test/helpers/validation-helpers.test.js | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/helpers/validation-helpers.test.js diff --git a/test/helpers/validation-helpers.test.js b/test/helpers/validation-helpers.test.js new file mode 100644 index 0000000..81b4a24 --- /dev/null +++ b/test/helpers/validation-helpers.test.js @@ -0,0 +1,33 @@ +const chai = require('chai'); +const sinon = require('sinon'); +const Twilio = require('twilio'); + +const validateSid = require('../../src/helpers/validation-helpers.js').validateSid; + +describe('validateSid', () => { + context( + 'when a chat service SID is valid', + () => { + it('returns true', () => { + const result = validateSid('IS', 'IS12345678901234567890123456789012'); + chai.expect(result).to.be.true; + }); + }, + ); + + context( + 'when a service SID is invalid', () => { + context('does not start with the correct prefix', () => { + it('returns false', () => { + const result = validateSid('IS', 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); + chai.expect(result).to.be.false; + }); + }) + context('is not 34 characters long', () => { + it('returns false', () => { + const result = validateSid('IS', 'IS1234567890'); + chai.expect(result).to.be.false; + }); + }) + }); +}); \ No newline at end of file From a07ae063b27220c8f77a88e1011c44a20184599b Mon Sep 17 00:00:00 2001 From: Mica Swyers Date: Mon, 16 Jun 2025 18:44:15 +0100 Subject: [PATCH 2/2] Fix things that biome is mad about --- package.json | 8 +--- test/helpers/validation-helpers.test.js | 52 +++++++++++-------------- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index fd399c6..4530ed0 100644 --- a/package.json +++ b/package.json @@ -29,17 +29,13 @@ "/yarn.lock" ], "homepage": "https://github.com/twilio-labs/plugin-token", - "keywords": [ - "oclif-plugin" - ], + "keywords": ["oclif-plugin"], "license": "MIT", "oclif": { "name": "token", "commands": "./src/commands", "bin": "twilio", - "devPlugins": [ - "@oclif/plugin-help" - ], + "devPlugins": ["@oclif/plugin-help"], "topics": { "token": { "description": "Generate a temporary token for use in test applications" diff --git a/test/helpers/validation-helpers.test.js b/test/helpers/validation-helpers.test.js index 81b4a24..a6b1474 100644 --- a/test/helpers/validation-helpers.test.js +++ b/test/helpers/validation-helpers.test.js @@ -1,33 +1,27 @@ const chai = require('chai'); -const sinon = require('sinon'); -const Twilio = require('twilio'); - -const validateSid = require('../../src/helpers/validation-helpers.js').validateSid; +const validateSid = + require('../../src/helpers/validation-helpers.js').validateSid; describe('validateSid', () => { - context( - 'when a chat service SID is valid', - () => { - it('returns true', () => { - const result = validateSid('IS', 'IS12345678901234567890123456789012'); - chai.expect(result).to.be.true; - }); - }, - ); + context('when a chat service SID is valid', () => { + it('returns true', () => { + const result = validateSid('IS', 'IS12345678901234567890123456789012'); + chai.expect(result).to.be.true; + }); + }); - context( - 'when a service SID is invalid', () => { - context('does not start with the correct prefix', () => { - it('returns false', () => { - const result = validateSid('IS', 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); - chai.expect(result).to.be.false; - }); - }) - context('is not 34 characters long', () => { - it('returns false', () => { - const result = validateSid('IS', 'IS1234567890'); - chai.expect(result).to.be.false; - }); - }) - }); -}); \ No newline at end of file + context('when a service SID is invalid', () => { + context('does not start with the correct prefix', () => { + it('returns false', () => { + const result = validateSid('IS', 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); + chai.expect(result).to.be.false; + }); + }); + context('is not 34 characters long', () => { + it('returns false', () => { + const result = validateSid('IS', 'IS1234567890'); + chai.expect(result).to.be.false; + }); + }); + }); +});