|
1 | 1 | local acronym = require('acronym') |
2 | 2 |
|
3 | 3 | describe('acronym', function() |
4 | | - it('should generate single-letter acronyms', function() |
5 | | - assert.equal('L', acronym('Lua')) |
| 4 | + it('basic', function() |
| 5 | + local input = "Portable Network Graphics" |
| 6 | + local expected = 'PNG' |
| 7 | + assert.equal(expected, acronym(input)) |
6 | 8 | end) |
7 | 9 |
|
8 | | - it('should generate multi-letter acronyms', function() |
9 | | - assert.equal('LUA', acronym('Lua Ultimate Acronym')) |
| 10 | + it('lowercase words', function() |
| 11 | + local input = "Ruby on Rails" |
| 12 | + local expected = 'ROR' |
| 13 | + assert.equal(expected, acronym(input)) |
10 | 14 | end) |
11 | 15 |
|
12 | | - it('should include lowercase words', function() |
13 | | - assert.equal('ROR', acronym('Ruby on Rails')) |
| 16 | + it('punctuation', function() |
| 17 | + local input = "First In, First Out" |
| 18 | + local expected = 'FIFO' |
| 19 | + assert.equal(expected, acronym(input)) |
14 | 20 | end) |
15 | 21 |
|
16 | | - it('should ignore punctuation', function() |
17 | | - assert.equal('FIFO', acronym('First In, First Out')) |
| 22 | + it('all caps word', function() |
| 23 | + local input = "GNU Image Manipulation Program" |
| 24 | + local expected = 'GIMP' |
| 25 | + assert.equal(expected, acronym(input)) |
18 | 26 | end) |
19 | 27 |
|
20 | | - it('should split words with internal capitalization', function() |
21 | | - assert.equal('HTML', acronym('HyperText Markup Language')) |
| 28 | + it('punctuation without whitespace', function() |
| 29 | + local input = "Complementary metal-oxide semiconductor" |
| 30 | + local expected = 'CMOS' |
| 31 | + assert.equal(expected, acronym(input)) |
22 | 32 | end) |
23 | 33 |
|
24 | | - it('should not split words that are all uppercase', function() |
25 | | - assert.equal('PHP', acronym('PHP: Hypertext Processor')) |
| 34 | + it('very long abbreviation', function() |
| 35 | + local input = "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" |
| 36 | + local expected = 'ROTFLSHTMDCOALM' |
| 37 | + assert.equal(expected, acronym(input)) |
| 38 | + end) |
| 39 | + |
| 40 | + it('consecutive delimiters', function() |
| 41 | + local input = "Something - I made up from thin air" |
| 42 | + local expected = 'SIMUFTA' |
| 43 | + assert.equal(expected, acronym(input)) |
| 44 | + end) |
| 45 | + |
| 46 | + it('apostrophes', function() |
| 47 | + local input = "Halley's Comet" |
| 48 | + local expected = 'HC' |
| 49 | + assert.equal(expected, acronym(input)) |
| 50 | + end) |
| 51 | + |
| 52 | + it('underscore emphasis', function() |
| 53 | + local input = "The Road _Not_ Taken" |
| 54 | + local expected = 'TRNT' |
| 55 | + assert.equal(expected, acronym(input)) |
26 | 56 | end) |
27 | 57 | end) |
0 commit comments