|
| 1 | +import {expression} from "../../src/qualifiers/expression"; |
| 2 | + |
| 3 | +const cases: Record<string, [string, string]> = { |
| 4 | + 'empty string is not affected': ['', ''], |
| 5 | + 'normalize greater than': ['$foo > $bar', '$foo_gt_$bar'], |
| 6 | + 'custom tags': ['if_!my_custom_tag! in tags', 'if_!my_custom_tag!_in_tags'], |
| 7 | + 'single space is replaced with a single underscore': [' ', '_'], |
| 8 | + 'blank string is replaced with a single underscore': [' ', '___'], |
| 9 | + 'underscore is not affected': ['_', '_'], |
| 10 | + 'sequence of underscores and spaces is changed to just underscores': [' _ __ _', '________'], |
| 11 | + 'arbitrary text is not affected': ['foobar', 'foobar'], |
| 12 | + 'duration is recognized as a variable and replaced with du': ['duration', 'du'], |
| 13 | + 'double ampersand replaced with and operator': ['foo && bar', 'foo_and_bar'], |
| 14 | + 'double ampersand with no space at the end is not affected': ['foo&&bar', 'foo&&bar'], |
| 15 | + 'width recognized as variable and replaced with w': ['width', 'w'], |
| 16 | + 'initial aspect ratio recognized as variable and replaced with iar': ['initial_aspect_ratio', 'iar'], |
| 17 | + '$width recognized as user variable and not affected': ['$width', '$width'], |
| 18 | + '$initial_aspect_ratio recognized as user variable followed by aspect_ratio variable': [ |
| 19 | + '$initial_aspect_ratio', |
| 20 | + '$initial_ar' |
| 21 | + ], |
| 22 | + '$mywidth recognized as user variable and not affected': ['$mywidth', '$mywidth'], |
| 23 | + '$widthwidth recognized as user variable and not affected': ['$widthwidth', '$widthwidth'], |
| 24 | + '$_width recognized as user variable and not affected': ['$_width', '$_width'], |
| 25 | + '$__width recognized as user variable and not affected': ['$__width', '$__width'], |
| 26 | + '$$width recognized as user variable and not affected': ['$$width', '$$width'], |
| 27 | + '$height recognized as user variable and not affected': ['$height_100', '$height_100'], |
| 28 | + '$heightt_100 recognized as user variable and not affected': ['$heightt_100', '$heightt_100'], |
| 29 | + '$$height_100 recognized as user variable and not affected': ['$$height_100', '$$height_100'], |
| 30 | + '$heightmy_100 recognized as user variable and not affected': ['$heightmy_100', '$heightmy_100'], |
| 31 | + '$myheight_100 recognized as user variable and not affected': ['$myheight_100', '$myheight_100'], |
| 32 | + '$heightheight_100 recognized as user variable and not affected': [ |
| 33 | + '$heightheight_100', |
| 34 | + '$heightheight_100' |
| 35 | + ], |
| 36 | + '$theheight_100 recognized as user variable and not affected': ['$theheight_100', '$theheight_100'], |
| 37 | + '$__height_100 recognized as user variable and not affected': ['$__height_100', '$__height_100'] |
| 38 | +}; |
| 39 | + |
| 40 | +describe('Tests for Transformation Action -- Variable', () => { |
| 41 | + it('tests expressions values', () => { |
| 42 | + Object.keys(cases).forEach(function (testDescription) { |
| 43 | + const [input, expected] = cases[testDescription]; |
| 44 | + expect(expression(input).toString()).toBe(expected); |
| 45 | + }); |
| 46 | + }); |
| 47 | +}); |
0 commit comments