mixedcase-names.js 768 B

1234567891011121314151617181920212223242526272829303132
  1. var test = require('tap').test
  2. var normalize = require('../')
  3. var fixer = normalize.fixer
  4. test('mixedcase', function (t) {
  5. t.doesNotThrow(function () {
  6. fixer.fixNameField({name: 'foo'}, true)
  7. })
  8. t.doesNotThrow(function () {
  9. fixer.fixNameField({name: 'foo'}, false)
  10. })
  11. t.doesNotThrow(function () {
  12. fixer.fixNameField({name: 'foo'})
  13. })
  14. t.throws(function () {
  15. fixer.fixNameField({name: 'Foo'}, true)
  16. }, new Error('Invalid name: "Foo"'), 'should throw an error')
  17. t.throws(function () {
  18. fixer.fixNameField({name: 'Foo'}, {strict: true})
  19. }, new Error('Invalid name: "Foo"'), 'should throw an error')
  20. t.doesNotThrow(function () {
  21. fixer.fixNameField({name: 'Foo'}, {strict: true, allowLegacyCase: true})
  22. })
  23. t.end()
  24. })