Skip to content

Commit 0ddd871

Browse files
committed
Additional tests for multiple backgrounds, use data URI for 'image/1.jpg'.
1 parent a225d79 commit 0ddd871

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

test/data-uri-example.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<div id="qunit-fixture"></div>
1414

1515
<script src="../background-check.min.js"></script>
16+
<script src="data-uri-example.js"></script>
1617
<script src="qunit.js"></script>
1718

1819
<!-- Basic markup -->

test/test-css-backgrounds.js

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,60 @@ asyncTest('Test CSS Backgrounds', function () {
1616
}, 'throws exception - elements are not images and do not have a background image');
1717

1818

19-
// Test for multiple backgrounds
19+
// Tests for multiple backgrounds
2020
var multiple = document.querySelector('.test--css-backgrounds .css-background--multiple');
2121

2222
throws(function () {
2323
BackgroundCheck.init({
2424
targets: '.test .target',
2525
images: multiple
2626
});
27-
}, 'throws exception - multiple backgrounds are not supported');
27+
}, 'throws exception - multiple backgrounds are not supported (1)');
28+
29+
throws(function () {
30+
multiple.style.backgroundImage = 'url(../examples/build/images/1.jpg), url(' + window.DataURI + ')';
31+
32+
BackgroundCheck.init({
33+
targets: '.test .target',
34+
images: multiple
35+
});
36+
}, 'throws exception - multiple backgrounds are not supported (2)');
37+
38+
throws(function () {
39+
multiple.style.backgroundImage = 'url(' + window.DataURI + '), url(../examples/build/images/1.jpg)';
40+
41+
BackgroundCheck.init({
42+
targets: '.test .target',
43+
images: multiple
44+
});
45+
}, 'throws exception - multiple backgrounds are not supported (3)');
46+
47+
throws(function () {
48+
multiple.style.backgroundImage = 'url(' + window.DataURI + '), url(' + window.DataURI + ')';
49+
50+
BackgroundCheck.init({
51+
targets: '.test .target',
52+
images: multiple
53+
});
54+
}, 'throws exception - multiple backgrounds are not supported (4)');
55+
56+
throws(function () {
57+
multiple.style.backgroundImage = 'url(' + window.DataURI + '), url(' + window.DataURI + '), url(' + window.DataURI + ')';
58+
59+
BackgroundCheck.init({
60+
targets: '.test .target',
61+
images: multiple
62+
});
63+
}, 'throws exception - multiple backgrounds are not supported (5)');
64+
65+
throws(function () {
66+
multiple.style.backgroundImage = 'url(../examples/build/images/1.jpg), url(../examples/build/images/1.jpg), url(../examples/build/images/1.jpg)';
67+
68+
BackgroundCheck.init({
69+
targets: '.test .target',
70+
images: multiple
71+
});
72+
}, 'throws exception - multiple backgrounds are not supported (6)');
2873

2974

3075
// Create elements first
@@ -36,12 +81,15 @@ asyncTest('Test CSS Backgrounds', function () {
3681
var element;
3782
var dash;
3883
var snippet;
84+
var url;
3985

4086
for (var e = 0; e < examples.length; e++) {
4187
snippet = snippets[e].innerHTML;
4288

89+
url = image === 1 ? window.DataURI : '../examples/build/images/' + image + '.jpg';
90+
4391
element = document.createElement('div');
44-
element.style.backgroundImage = 'url("../examples/build/images/' + image + '.jpg")';
92+
element.style.backgroundImage = 'url(' + url + ')';
4593
element.className = 'css-background-image';
4694

4795
css = snippet.split(';');

0 commit comments

Comments
 (0)