|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const genericNames = require('../index'); |
| 4 | +const test = require('tape'); |
| 5 | + |
| 6 | +// According to the CSS spec, identifiers cannot |
| 7 | +// start with a digit, two hyphens, or a hyphen |
| 8 | +// followed by a digit. |
| 9 | +// |
| 10 | +// relates: https://github.com/webpack/css-loader/commit/da27c07d0df25a38699344c13b6614c53a469fd9 |
| 11 | + |
| 12 | +test('identity', t => { |
| 13 | + const generate = genericNames('[local]'); |
| 14 | + |
| 15 | + t.equal(generate('foo', '/test/case/source.css'), 'foo'); |
| 16 | + t.end(); |
| 17 | +}); |
| 18 | + |
| 19 | +test('leading digit', t => { |
| 20 | + const generate = genericNames('0[local]'); |
| 21 | + |
| 22 | + t.equal(generate('foo', '/test/case/source.css'), '_0foo'); |
| 23 | + t.end(); |
| 24 | +}); |
| 25 | + |
| 26 | +test('leading digit in the token', t => { |
| 27 | + const generate = genericNames('[local]'); |
| 28 | + |
| 29 | + t.equal(generate('0foo', '/test/case/source.css'), '_0foo'); |
| 30 | + t.end(); |
| 31 | +}); |
| 32 | + |
| 33 | +test('leading two hyphens', t => { |
| 34 | + const generate = genericNames('--[local]'); |
| 35 | + |
| 36 | + t.equal(generate('foo', '/test/case/source.css'), '_--foo'); |
| 37 | + t.end(); |
| 38 | +}); |
| 39 | + |
| 40 | +test('leading hyphen and digit', t => { |
| 41 | + const generate = genericNames('-0[local]'); |
| 42 | + |
| 43 | + t.equal(generate('foo', '/test/case/source.css'), '_-0foo'); |
| 44 | + t.end(); |
| 45 | +}); |
0 commit comments