forked from postcss/postcss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeclaration.es6
44 lines (32 loc) · 1.29 KB
/
declaration.es6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Declaration from '../lib/declaration';
import parse from '../lib/parse';
import Rule from '../lib/rule';
import { expect } from 'chai';
describe('Declaration', () => {
it('initializes with properties', () => {
let decl = new Declaration({ prop: 'color', value: 'black' });
expect(decl.prop).to.eql('color');
expect(decl.value).to.eql('black');
});
describe('important', () => {
it('returns boolean', () => {
let decl = new Declaration({ prop: 'color', value: 'black' });
decl.important = true;
expect(decl.toString()).to.eql('color: black !important');
});
});
describe('toString()', () => {
it('inserts default spaces', () => {
let decl = new Declaration({ prop: 'color', value: 'black' });
let rule = new Rule({ selector: 'a' });
rule.append(decl);
expect(rule.toString()).to.eql('a {\n color: black\n}');
});
it('clones spaces from another declaration', () => {
let root = parse('a{color:black}');
let decl = new Declaration({ prop: 'margin', value: '0' });
root.first.append(decl);
expect(root.toString()).to.eql('a{color:black;margin:0}');
});
});
});