| Conditions | 1 |
| Paths | 1 |
| Total Lines | 67 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | 'use strict'; |
||
| 6 | describe('icls-parser', function () { |
||
| 7 | describe('parse', function () { |
||
| 8 | |||
| 9 | it('should return an object with the name', function () { |
||
| 10 | const iclsSample = '<scheme name="Material Peacock Optimized" version="142">' + |
||
| 11 | '</scheme>'; |
||
| 12 | |||
| 13 | const parsed = parser.parse(iclsSample); |
||
| 14 | |||
| 15 | expect(parsed).to.have.property('name', 'Material Peacock Optimized'); |
||
| 16 | expect(parsed).to.have.property('version', 142); |
||
| 17 | |||
| 18 | }); |
||
| 19 | |||
| 20 | |||
| 21 | it('should return an object with the first level options', function () { |
||
| 22 | const iclsSample = '<scheme name="Material Peacock Optimized" version="142">' + |
||
| 23 | ' <option name="FONT_SCALE" value="1.0" />' + |
||
| 24 | ' <option name="LINE_SPACING" value="1.2" />' + |
||
| 25 | ' <option name="EDITOR_FONT_SIZE" value="12" />' + |
||
| 26 | ' <option name="EDITOR_FONT_NAME" value="Fira Code" />' + |
||
| 27 | ' <option name="EDITOR_LIGATURES" value="true" />' + |
||
| 28 | ' <option name="CONSOLE_FONT_NAME" value="Menlo" />' + |
||
| 29 | ' <option name="CONSOLE_LINE_SPACING" value="1.4" />' + |
||
| 30 | '</scheme>'; |
||
| 31 | |||
| 32 | const parsed = parser.parse(iclsSample); |
||
| 33 | |||
| 34 | expect(parsed).to.have.property('name', 'Material Peacock Optimized'); |
||
| 35 | expect(parsed).to.have.property('version', 142); |
||
| 36 | expect(parsed).to.have.property('font_scale', 1.0); |
||
| 37 | expect(parsed).to.have.property('line_spacing', 1.2); |
||
| 38 | expect(parsed).to.have.property('editor_font_size', 12); |
||
| 39 | expect(parsed).to.have.property('editor_font_name', 'Fira Code'); |
||
| 40 | expect(parsed).to.have.property('editor_ligatures', true); |
||
| 41 | expect(parsed).to.have.property('console_font_name', 'Menlo'); |
||
| 42 | expect(parsed).to.have.property('console_line_spacing', 1.4); |
||
| 43 | |||
| 44 | }); |
||
| 45 | |||
| 46 | |||
| 47 | it('should return an object with the colors', function () { |
||
| 48 | const iclsSample = '<scheme>' + |
||
| 49 | ' <colors>' + |
||
| 50 | ' <option name="ADDED_LINES_COLOR" value="5f7210" />' + |
||
| 51 | ' <option name="ANNOTATIONS_COLOR" value="8b999f" />' + |
||
| 52 | ' <option name="CARET_COLOR" value="60999d" />' + |
||
| 53 | ' <option name="CARET_ROW_COLOR" value="c1418" />' + |
||
| 54 | ' <option name="CONSOLE_BACKGROUND_KEY" value="" />' + |
||
| 55 | ' </colors>' + |
||
| 56 | '</scheme>'; |
||
| 57 | |||
| 58 | const parsed = parser.parse(iclsSample); |
||
| 59 | |||
| 60 | expect(parsed).to.have.property('colors'); |
||
| 61 | |||
| 62 | const colors = parsed.colors; |
||
| 63 | |||
| 64 | expect(colors).to.have.property('added_lines_color', "5f7210"); |
||
| 65 | expect(colors).to.have.property('annotations_color', "8b999f"); |
||
| 66 | expect(colors).to.have.property('caret_color', "60999d"); |
||
| 67 | expect(colors).to.have.property('caret_row_color', "c1418"); |
||
| 68 | expect(colors).to.have.property('console_background_key', ""); |
||
| 69 | }); |
||
| 70 | |||
| 71 | }); |
||
| 72 | }); |
||
| 73 |