1 | import { background } from "../src/background";
|
2 | import * as assert from 'assert';
|
3 |
|
4 | describe("csx/background", () => {
|
5 | it("returns empty string when no backgrounds are supplied", () => {
|
6 | const empty = background();
|
7 | assert.equal(empty, '');
|
8 | });
|
9 |
|
10 | it("returns empty string when no background properties are supplied", () => {
|
11 | const empty = background({});
|
12 | assert.equal(empty, '');
|
13 | });
|
14 |
|
15 | it("returns empty string when multiple arguments without background properties are supplied", () => {
|
16 | const empty = background({}, {});
|
17 | assert.equal(empty, '');
|
18 | });
|
19 |
|
20 | it("returns valid background shorthand for few properties", () => {
|
21 | const bkg = background({
|
22 | color: 'green',
|
23 | image: 'url("test.jpg")',
|
24 | repeat: 'repeat-y'
|
25 | });
|
26 | assert.equal(bkg, 'url("test.jpg") repeat-y green');
|
27 | });
|
28 |
|
29 | it("returns valid background shorthand for all properties", () => {
|
30 | const bkg = background({
|
31 | image: 'url("test.jpg")',
|
32 | position: 'center',
|
33 | size: '50% auto',
|
34 | repeat: 'repeat-x',
|
35 | origin: 'padding-box',
|
36 | clip: 'text',
|
37 | attachment: 'fixed',
|
38 | color: 'red'
|
39 | });
|
40 | assert.equal(bkg, 'url("test.jpg") center/50% auto repeat-x padding-box text fixed red');
|
41 | });
|
42 |
|
43 | it("returns valid background shorthand for multiple backgrounds", () => {
|
44 | const bkg = background(
|
45 | {
|
46 | image: 'url("test.jpg")',
|
47 | position: 'center',
|
48 | size: '50% auto',
|
49 | repeat: 'repeat-x',
|
50 | origin: 'padding-box',
|
51 | clip: 'text',
|
52 | attachment: 'fixed',
|
53 | color: 'red'
|
54 | },
|
55 | {
|
56 | color: 'green',
|
57 | image: 'url("test.jpg")',
|
58 | repeat: 'repeat-y'
|
59 | });
|
60 | assert.equal(bkg, 'url("test.jpg") center/50% auto repeat-x padding-box text fixed red, url("test.jpg") repeat-y green');
|
61 | });
|
62 |
|
63 | it("returns valid background shorthand for more than two backgrounds", () => {
|
64 | const bkg = background(
|
65 | { color: 'red' },
|
66 | { color: 'yellow' },
|
67 | { color: 'green' }
|
68 | );
|
69 | assert.equal(bkg, 'red, yellow, green');
|
70 | });
|
71 | });
|