Skip to content

Commit

Permalink
adds tests for universal selector
Browse files Browse the repository at this point in the history
  • Loading branch information
GGAlanSmithee committed Nov 4, 2015
1 parent 0b67887 commit 2c407e1
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions test/universal-selector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { expect } from 'chai';

import { parse } from 'css';

import { toObject } from './../src/objectify';

describe('toObject(stylesheet)', function() {
describe('objectifies universal selector', () => {
it('one element', () => {
const expected = {
'*' : {
border: '1px solid black'
}
};

const actual = toObject(parse(`* { border: 1px solid black; }`).stylesheet);

expect(actual).to.deep.equal(expected);
});

it('re-accuring element', () => {
const expected = {
'*' : {
border: '1px solid black',
position: 'relative',
display: 'inline-block',
color: 'white'
}
};

const actual = toObject(parse(
`* {
border: 1px solid black;
position: relative;
}
* {
display: inline-block;
}
* {
color: white;
}`
).stylesheet);

expect(actual).to.deep.equal(expected);
});

it('re-accuring element with conflicting (overriding) styles', () => {
const expected = {
'*' : {
border: '1px solid black',
position: 'absolute',
display: 'inline-block'
}
};

const actual = toObject(parse(
`* {
border: 1px solid black;
position: relative;
}
* {
display: inline-block;
}
* {
position: absolute;
}`
).stylesheet);

expect(actual).to.deep.equal(expected);
});
});
});

0 comments on commit 2c407e1

Please sign in to comment.