|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +import {siteNameToPackageName} from '../utils'; |
| 9 | + |
| 10 | +describe('siteNameToPackageName', () => { |
| 11 | + it('converts simple cases', () => { |
| 12 | + const testCases: [string, string][] = [ |
| 13 | + ['Foo Bar', 'foo-bar'], |
| 14 | + ['fooBar', 'foo-bar'], |
| 15 | + ['__FOO_BAR__', 'foo-bar'], |
| 16 | + ['XMLHttpRequest', 'xml-http-request'], |
| 17 | + ['sitemapXML', 'sitemap-xml'], |
| 18 | + ['XMLHttp', 'xml-http'], |
| 19 | + ['xml-http', 'xml-http'], |
| 20 | + ]; |
| 21 | + |
| 22 | + testCases.forEach(([input, expected]) => { |
| 23 | + expect(siteNameToPackageName(input)).toEqual(expected); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + it('converts ñ', () => { |
| 28 | + expect(siteNameToPackageName('mañanaFoo')).toEqual('ma-ana-foo'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('converts __', () => { |
| 32 | + expect(siteNameToPackageName('foo__bar')).toEqual('foo-bar'); |
| 33 | + }); |
| 34 | + |
| 35 | + it('skips 🔥', () => { |
| 36 | + expect(siteNameToPackageName('🔥')).toEqual('🔥'); |
| 37 | + }); |
| 38 | + |
| 39 | + it('skips !!!', () => { |
| 40 | + expect(siteNameToPackageName('!!!')).toEqual('!!!'); |
| 41 | + }); |
| 42 | +}); |
0 commit comments