Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 'use strict'
  2. var validate = require('..')
  3. var test = require('tap').test
  4. test('validate-npm-package-name', function (t) {
  5. // Traditional
  6. t.deepEqual(validate('some-package'), {validForNewPackages: true, validForOldPackages: true})
  7. t.deepEqual(validate('example.com'), {validForNewPackages: true, validForOldPackages: true})
  8. t.deepEqual(validate('under_score'), {validForNewPackages: true, validForOldPackages: true})
  9. t.deepEqual(validate('period.js'), {validForNewPackages: true, validForOldPackages: true})
  10. t.deepEqual(validate('123numeric'), {validForNewPackages: true, validForOldPackages: true})
  11. t.deepEqual(validate('crazy!'), {
  12. validForNewPackages: false,
  13. validForOldPackages: true,
  14. warnings: ['name can no longer contain special characters ("~\'!()*")']
  15. })
  16. // Scoped (npm 2+)
  17. t.deepEqual(validate('@npm/thingy'), {validForNewPackages: true, validForOldPackages: true})
  18. t.deepEqual(validate('@npm-zors/money!time.js'), {
  19. validForNewPackages: false,
  20. validForOldPackages: true,
  21. warnings: ['name can no longer contain special characters ("~\'!()*")']
  22. })
  23. // Invalid
  24. t.deepEqual(validate(''), {
  25. validForNewPackages: false,
  26. validForOldPackages: false,
  27. errors: ['name length must be greater than zero']})
  28. t.deepEqual(validate(''), {
  29. validForNewPackages: false,
  30. validForOldPackages: false,
  31. errors: ['name length must be greater than zero']})
  32. t.deepEqual(validate('.start-with-period'), {
  33. validForNewPackages: false,
  34. validForOldPackages: false,
  35. errors: ['name cannot start with a period']})
  36. t.deepEqual(validate('_start-with-underscore'), {
  37. validForNewPackages: false,
  38. validForOldPackages: false,
  39. errors: ['name cannot start with an underscore']})
  40. t.deepEqual(validate('contain:colons'), {
  41. validForNewPackages: false,
  42. validForOldPackages: false,
  43. errors: ['name can only contain URL-friendly characters']})
  44. t.deepEqual(validate(' leading-space'), {
  45. validForNewPackages: false,
  46. validForOldPackages: false,
  47. errors: ['name cannot contain leading or trailing spaces', 'name can only contain URL-friendly characters']})
  48. t.deepEqual(validate('trailing-space '), {
  49. validForNewPackages: false,
  50. validForOldPackages: false,
  51. errors: ['name cannot contain leading or trailing spaces', 'name can only contain URL-friendly characters']})
  52. t.deepEqual(validate('s/l/a/s/h/e/s'), {
  53. validForNewPackages: false,
  54. validForOldPackages: false,
  55. errors: ['name can only contain URL-friendly characters']})
  56. t.deepEqual(validate('node_modules'), {
  57. validForNewPackages: false,
  58. validForOldPackages: false,
  59. errors: ['node_modules is a blacklisted name']})
  60. t.deepEqual(validate('favicon.ico'), {
  61. validForNewPackages: false,
  62. validForOldPackages: false,
  63. errors: ['favicon.ico is a blacklisted name']})
  64. // Node/IO Core
  65. t.deepEqual(validate('http'), {
  66. validForNewPackages: false,
  67. validForOldPackages: true,
  68. warnings: ['http is a core module name']})
  69. // Long Package Names
  70. t.deepEqual(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou-'), {
  71. validForNewPackages: false,
  72. validForOldPackages: true,
  73. warnings: ['name can no longer contain more than 214 characters']
  74. })
  75. t.deepEqual(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou'), {
  76. validForNewPackages: true,
  77. validForOldPackages: true
  78. })
  79. // Legacy Mixed-Case
  80. t.deepEqual(validate('CAPITAL-LETTERS'), {
  81. validForNewPackages: false,
  82. validForOldPackages: true,
  83. warnings: ['name can no longer contain capital letters']})
  84. t.end()
  85. })