|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const expect = require('chai').expect; |
| 4 | +const Parser = require('../lib/parser'); |
| 5 | +const ParserError = require('../lib/errors/ParserError'); |
| 6 | + |
| 7 | +describe('Parser → Number', () => { |
| 8 | + let fixtures = [ |
| 9 | + { |
| 10 | + it: 'should clone an rgb function', |
| 11 | + test: 'rgb(255, 0, 0)', |
| 12 | + expected: [ |
| 13 | + { type: 'func', value: 'rgb' }, |
| 14 | + { type: 'paren', value: '(' }, |
| 15 | + { type: 'number', value: '255' }, |
| 16 | + { type: 'comma', value: ',' }, |
| 17 | + { type: 'number', value: '0' }, |
| 18 | + { type: 'comma', value: ',' }, |
| 19 | + { type: 'number', value: '0' }, |
| 20 | + { type: 'paren', value: ')' } |
| 21 | + ] |
| 22 | + } |
| 23 | + ]; |
| 24 | + |
| 25 | + fixtures.forEach((fixture) => { |
| 26 | + it(fixture.it, () => { |
| 27 | + let ast = new Parser(fixture.test, { loose: fixture.loose }).parse().clone(), |
| 28 | + index = 0; |
| 29 | + |
| 30 | + ast.first.walk((node) => { |
| 31 | + let expected = fixture.expected[index]; |
| 32 | + index ++; |
| 33 | + |
| 34 | + if (expected) { |
| 35 | + expect(node).to.shallowDeepEqual(expected); |
| 36 | + } |
| 37 | + }); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | +}); |
0 commit comments