Created
October 3, 2021 16:04
-
-
Save shrutiburman/f153b76d9a60c0a04a258a1d4c997a69 to your computer and use it in GitHub Desktop.
DII-136 Testing Gist
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
sburman@C02FQ9QFMD6M twilio-cli % npm run test | |
> twilio-cli@2.30.2 test | |
> nyc mocha --forbid-only "test/**/*.test.js" | |
base-commands | |
twilio-api-command | |
TwilioApiCommand | |
✓ setUpNewCommandClass | |
✓ checks that parameters with inequalities convert to the correct flag names | |
✓ checks the help document url | |
✓ checks the help document url | |
✓ handles remove action | |
✓ creates a call | |
✓ lists calls | |
✓ deletes a call | |
✓ updates a call | |
✓ exits with a failure code and prints validation errors (152ms) | |
✓ creates a call with an invalid parameter | |
✓ adds header parameters | |
debugger:logs:list | |
historical | |
✓ prints alert/log events (1548ms) | |
✓ prints errors | |
✓ accepts date args | |
✓ prints errors | |
streaming | |
✓ streams and then quits (2020ms) | |
✓ does not like end dates when steaming | |
✓ does not like futuristic start dates | |
commands | |
send | |
✓ run email:send with no environment variable for SendGrid key | |
✓ run email:send without defaults and with multiple recipients including an incorrect to email address | |
✓ run email:send with filled out inquirer prompts | |
✓ run email:send use inquire and a flag to set information | |
✓ run email:send without defaults and an invalid from email address | |
✓ run email:send with default subject line and sending email address | |
✓ run email:send with defaults and multiple recipients | |
✓ run email:send with all flags | |
✓ run email:send with flags and default subject line | |
✓ run email:send using flags to set information using relative file path | |
✓ run email:send using flags to set information using invalid file path | |
✓ run email:send using flags to set information using tilde in file path | |
✓ run email:send with default subject line and sending email address and relative path for attachment | |
✓ runs email:send without an attachment or prompt for one | |
✓ run email:send using stdin as the attachment source (116ms) | |
✓ run email:send using stdin as the attachment source but missing a To | |
✓ run email:send with an attachment and set the correct content-type for plaintext files | |
✓ run email:send with an attachment and set the correct content-type for non-text files | |
✓ run email:send with an attachment and fall back to text/plain for unknown file types | |
commands | |
set | |
✓ run email:set to set a new default sending email and subject with flags | |
✓ run email:set to set a new default sending email and subject | |
✓ run email:set to set a new default sending email and subject when a default has already been setup | |
✓ run email:set with invalid email and correct subject line when a default has already been set up | |
commands | |
feedback | |
✓ runs feedback | |
commands | |
phone-numbers | |
list | |
✓ runs incoming-phone-number:list | |
✓ runs incoming-phone-number:list with custom properties | |
commands | |
phone-numbers | |
update | |
✓ runs incoming-phone-number:update PN1234567890abcdef1234567890abcdef --friendly-name <name> | |
✓ runs incoming-phone-number:update PN1234567890abcdef1234567890abcdef --sms-url <url> | |
✓ should return nothing to update if no properties passed | |
✓ runs incoming-phone-number:update PN1234567890abcdef1234567890abcdef --sms-url <LOCALHOST url> and starts ngrok | |
✓ runs incoming-phone-number:update PN1234567890abcdef1234567890abcdef --sms-url <https LOCALHOST url> and starts ngrok | |
» WARNING: Detected localhost URL. | |
» For convenience, we will automatically create an encrypted tunnel using the 3rd-party service https://ngrok.io | |
» While running, this will expose your computer to the internet. | |
» Please exit this command after testing. | |
twilio-cli configuration saved to "/var/folders/6y/k70wgpzs1lv7f9rv04m376h00000gn/T/tmp-35875-Ny0MOq4OzK9I/config.json" | |
✓ runs incoming-phone-number:update PN1234567890abcdef1234567890abcdef --sms-url <https LOCALHOST url> and catches the ngrok error | |
✓ runs incoming-phone-number:update with multiple urls and multiple ngrok tunnels | |
✓ handles generic ngrok errors | |
✓ handles complex ngrok errors | |
commands | |
plugins | |
available | |
✓ should print out available plugins | |
✓ should not print out installed plugins | |
commands | |
profiles | |
create | |
✓ runs profiles:create | |
✓ truncates apiKeyFriendlyName to 64 characters | |
✓ handles bad user info (1449ms) | |
✓ fails for invalid account SIDs | |
✓ fails for invalid Auth Tokens | |
✓ can skip parameter validation | |
✓ prompts when creating default profile with env vars set (1216ms) | |
✓ fails for invalid credentials | |
✓ fails to create an API key | |
✓ fails early if keytar cannot be loaded | |
✓ supports other regions | |
commands | |
profiles | |
list | |
✓ runs profiles:list with no profiles | |
✓ runs profiles:list with 1 profile | |
✓ runs profiles:list with environment variables set | |
✓ runs profiles:list with multiple profiles | |
✓ when the active profile is set | |
✓ runs profiles:list with 1 regional profile | |
commands | |
profiles | |
remove | |
✓ run profiles:remove with a profile and delets local key but keep remote key | |
✓ run profiles:remove with a profile and fails to delete both keys | |
✓ run profiles:remove with the active profile and deletes both keys | |
✓ run profiles:remove with profile and deletes local key but can not delete remote key (1160ms) | |
✓ run profiles:remove with a profile and decide not to remove profile | |
✓ run profiles:remove with the last configured profile and delete all keys | |
✓ run profiles:remove with non-existing profile | |
commands | |
profiles | |
use | |
✓ should set the active profile with id | |
✓ run profiles:active with non-existing profile | |
commands | |
zork | |
✓ tries to install zork and fails | |
✓ tries to install zork and runs it | |
hooks | |
command-not-found | |
✓ warns and installs non-installed plugin topics | |
✓ warns and install non-installed plugins commands | |
✓ does nothing for installed plugins or unknown commands | |
hooks | |
init | |
buy-phone-number | |
✓ creates the proper commands | |
✓ allows purchasing a phone number (49ms) | |
✓ does nothing if the API commands plugin is not found | |
✓ does nothing if no phone number list commands are found | |
✓ does nothing if the phone number create command is not found | |
hooks | |
init | |
plugin-verification | |
✓ outputs nothing for just core plugins | |
✓ outputs nothing if no conflicts in installed plugins | |
✓ warns for each conflicting command | |
hooks | |
init | |
twilio-api | |
✓ provides multiple resources and actions (230ms) | |
hooks | |
plugin-install | |
✓ warning when non Twilio plugin is installed | |
✓ warning when plugin is undefined | |
✓ outputs nothing when Twilio plugin is installed | |
services/api-schema | |
json-validator | |
[DEBUG] No validation function for "object" schema type | |
✓ handles new schema types | |
[DEBUG] No validation function for "password" schema format | |
✓ handles new string formats | |
array-type | |
✓ validates happy paths | |
✓ reports too few items | |
✓ reports too many items | |
✓ reports unique constraint violations | |
✓ reports nested value violations | |
✓ reports invalid types | |
boolean-type | |
✓ validates happy paths | |
✓ reports invalid booleans | |
integer-type | |
✓ validates happy paths | |
✓ reports invalid integers | |
✓ reports min violations | |
✓ reports max violations | |
✓ reports multiple-of violations | |
✓ reports multiple violations | |
number-type | |
✓ validates happy paths | |
✓ reports invalid numbers | |
string-type | |
✓ validates happy paths | |
✓ reports bad values | |
string-type-enum | |
✓ validates happy paths | |
✓ reports bad values | |
string-type-date | |
✓ validates happy paths | |
✓ reports bad values | |
string-type-date-time | |
✓ validates happy paths | |
✓ reports bad values | |
string-type-uri | |
✓ validates happy paths | |
✓ reports bad values | |
services/api-schema | |
twilio-validator | |
string-type-date | |
✓ accepts any string | |
✓ reports non-strings | |
string-type-date-time | |
✓ accepts any string | |
✓ reports non-strings | |
string-type-uri | |
✓ accepts any string | |
✓ reports non-strings | |
supportsHyperlink | |
test hyperlink generation | |
test for Mac terminals | |
✓ not supported in Mac Terminal | |
test for iTerm terminals | |
✓ testing convertToHyperlink, supported iTerm.app 3.1, tty stream | |
✓ supported in iTerm.app 3.1, tty stream | |
test for Windows | |
✓ supported in Windows Terminal | |
convertToHyperlink | |
test for iTerm | |
test hyperlink generation for dummyURL and dummyText on macOS | |
✓ verify the contents of dummy Command | |
utility | |
resource-helpers | |
api | |
v2010 | |
incoming-phone-number | |
✓ finds number by valid sid (658ms) | |
✓ doesn't find number by invalid sid | |
✓ handles error looking up phone number sid | |
✓ finds number by valid phone number | |
✓ doesn't find number by invalid phone number | |
✓ handles error looking up phone number | |
services | |
twilio-api | |
getTopicName | |
✓ handles a simple, non-nested resource path | |
✓ handles a nested resource path with parameters | |
✓ handles v2010 APIs | |
getActionDescription | |
✓ returns existing action description | |
✓ returns a default List action description | |
✓ returns a default Create action description | |
✓ returns a default Fetch action description | |
✓ returns a default Remove action description | |
✓ handles actions with maturity | |
✓ ignores GA maturity level | |
✓ handles actions with maturity and descriptions | |
✓ handles actions with multiple maturities and description | |
getDocLink | |
✓ handles a simple core api | |
✓ handles another topic | |
✓ checks for an api which doesnt have a specific reference doc | |
✓ checks for command that doesnt have any reference doc, returns default url | |
✓ handles a command | |
✓ handles an api with subroute url | |
✓ handles an api with subroute url | |
✓ handles the json with empty api list {} | |
getFlagConfig : checking for hyperlink in markdowns | |
✓ handles a description on a supported terminal : iTerm | |
✓ handles a description which doesnt match the regex, on a supported terminal : iTerm | |
✓ handles a description on a non-supported terminal : MAC | |
should show help doc url correctly | |
✓ Checks for a docLink for a topic | |
✓ Checks when doc link is undefined, fetches default url from getDocLink method | |
✓ Checks for the document link for a command | |
should log help | |
✓ Should display required flags | |
✓ Should not display required flags if not configured | |
✓ Should not display Options in case no flags configured | |
173 passing (10s) | |
-------------------------------------|---------|----------|---------|---------|----------------------------- | |
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | |
-------------------------------------|---------|----------|---------|---------|----------------------------- | |
All files | 97.8 | 92.69 | 97.45 | 97.91 | | |
base-commands | 96 | 85.71 | 100 | 95.83 | | |
twilio-api-command.js | 96 | 85.71 | 100 | 95.83 | 97,102 | |
commands | 100 | 100 | 100 | 100 | | |
feedback.js | 100 | 100 | 100 | 100 | | |
zork.js | 100 | 100 | 100 | 100 | | |
commands/debugger/logs | 97.83 | 100 | 100 | 97.73 | | |
list.js | 97.83 | 100 | 100 | 97.73 | 90 | |
commands/email | 100 | 100 | 100 | 100 | | |
send.js | 100 | 100 | 100 | 100 | | |
set.js | 100 | 100 | 100 | 100 | | |
commands/phone-numbers | 95.95 | 89.66 | 87.5 | 95.89 | | |
list.js | 100 | 100 | 100 | 100 | | |
update.js | 95.45 | 89.66 | 85.71 | 95.38 | 39,87,134 | |
commands/plugins | 100 | 100 | 100 | 100 | | |
available.js | 100 | 100 | 100 | 100 | | |
commands/profiles | 95.88 | 84.29 | 90.63 | 95.83 | | |
create.js | 93.04 | 77.08 | 85.71 | 93.04 | 63,72,82,94,101,115,169-181 | |
list.js | 100 | 100 | 100 | 100 | | |
remove.js | 100 | 100 | 100 | 100 | | |
use.js | 100 | 100 | 100 | 100 | | |
hooks | 100 | 80 | 100 | 100 | | |
command-not-found.js | 100 | 83.33 | 100 | 100 | 29 | |
plugin-install.js | 100 | 75 | 100 | 100 | 19 | |
hooks/init | 95.88 | 86.36 | 97.56 | 96.2 | | |
buy-phone-number.js | 96.2 | 80 | 93.33 | 97.3 | 47,66 | |
plugin-verification.js | 100 | 100 | 100 | 100 | | |
twilio-api.js | 93.85 | 83.33 | 100 | 93.65 | 95,100-102 | |
services | 98.28 | 93.75 | 100 | 98.11 | | |
email-utility.js | 100 | 100 | 100 | 100 | | |
file-io.js | 100 | 100 | 100 | 100 | | |
hyperlink-utility.js | 91.67 | 83.33 | 100 | 91.67 | 9 | |
plugins.js | 100 | 100 | 100 | 100 | | |
services/api-schema | 100 | 97.37 | 100 | 100 | | |
json-validator.js | 100 | 97.37 | 100 | 100 | 85,94 | |
schema-validator.js | 100 | 100 | 100 | 100 | | |
twilio-validator.js | 100 | 100 | 100 | 100 | | |
services/messaging | 100 | 100 | 100 | 100 | | |
help-messages.js | 100 | 100 | 100 | 100 | | |
templates.js | 100 | 100 | 100 | 100 | | |
services/resource-helpers/api/v2010 | 100 | 100 | 100 | 100 | | |
incoming-phone-number.js | 100 | 100 | 100 | 100 | | |
services/twilio-api | 100 | 98.41 | 100 | 100 | | |
api-command-runner.js | 100 | 94.12 | 100 | 100 | 69 | |
get-action-description.js | 100 | 100 | 100 | 100 | | |
get-flag-config.js | 100 | 100 | 100 | 100 | | |
get-help-doc-link.js | 100 | 100 | 100 | 100 | | |
get-topic-name.js | 100 | 100 | 100 | 100 | | |
index.js | 100 | 100 | 100 | 100 | | |
services/twilio-help | 97.26 | 88.64 | 100 | 98.48 | | |
custom-help.js | 100 | 100 | 100 | 100 | | |
twilio-command-help.js | 97.06 | 88.64 | 100 | 98.36 | 43 | |
-------------------------------------|---------|----------|---------|---------|----------------------------- | |
> twilio-cli@2.30.2 posttest | |
> npm run lint && npm audit | |
> twilio-cli@2.30.2 lint | |
> eslint --ext js --ext jsx src/ test/ | |
found 0 vulnerabilities | |
sburman@C02FQ9QFMD6M twilio-cli % |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment