mirror of
https://github.com/hanzoai/postcss.git
synced 2026-09-24 17:01:56 +00:00
60 lines
1.7 KiB
CoffeeScript
60 lines
1.7 KiB
CoffeeScript
Declaration = require('../lib/declaration')
|
|
parse = require('../lib/parse')
|
|
|
|
describe 'Declaration', ->
|
|
|
|
it 'initializes with properties', ->
|
|
decl = new Declaration(prop: 'color', value: 'black')
|
|
|
|
decl.prop.should.eql('color')
|
|
decl.value.should.eql('black')
|
|
|
|
describe 'important', ->
|
|
|
|
it 'returns boolean', ->
|
|
decl = new Declaration
|
|
prop: 'color'
|
|
value: 'black'
|
|
_important: ' !important'
|
|
|
|
decl.important.should.be.true
|
|
|
|
it 'adds virtual property', ->
|
|
decl = new Declaration(prop: 'color', value: 'black', before: '')
|
|
decl.important.should.be.false
|
|
|
|
decl.important = true
|
|
decl.important.should.be.true
|
|
decl.toString().should.eql 'color: black !important'
|
|
|
|
decl.important = ' !important /*very*/'
|
|
decl.important.should.be.true
|
|
decl.toString().should.eql 'color: black !important /*very*/'
|
|
|
|
decl.important = false
|
|
decl.important.should.be.false
|
|
decl.toString().should.eql 'color: black'
|
|
|
|
describe 'clone()', ->
|
|
|
|
it 'cleans parent and before', ->
|
|
decl = new Declaration(prop: 'color', value: 'black', before: "\n ")
|
|
clone = decl.clone(value: 'white')
|
|
|
|
clone.value.should.eql('white')
|
|
(clone.parent == undefined).should.be.true
|
|
(clone.before == undefined).should.be.true
|
|
|
|
describe 'toString()', ->
|
|
|
|
it 'inserts default spaces', ->
|
|
decl = new Declaration(prop: 'color', value: 'black')
|
|
decl.toString().should.eql("\n color: black")
|
|
|
|
it 'clone spaces from another declaration', ->
|
|
root = parse('a{color:black}')
|
|
decl = new Declaration(prop: 'margin', value: '0')
|
|
root.first.append(decl)
|
|
|
|
decl.toString().should.eql('margin:0')
|