aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2014-04-28 11:51:35 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2014-04-28 11:51:35 +0200
commit635e51f8f54ba519c7b865b7b4f62cb65a927d2f (patch)
tree996e164af994d99a43f712463570cda7b1bc1cdd /test
parent9873839a50bffa9ef57050cf583588db2f66fde6 (diff)
downloadperl-software-in-gnu-guix-635e51f8f54ba519c7b865b7b4f62cb65a927d2f.tar
perl-software-in-gnu-guix-635e51f8f54ba519c7b865b7b4f62cb65a927d2f.tar.gz
addition background image and getSlideBackground tests
Diffstat (limited to 'test')
-rw-r--r--test/test.html4
-rw-r--r--test/test.js19
2 files changed, 17 insertions, 6 deletions
diff --git a/test/test.html b/test/test.html
index edb1623..29d02a9 100644
--- a/test/test.html
+++ b/test/test.html
@@ -19,13 +19,13 @@
<div class="slides">
- <section>
+ <section data-background-image="examples/assets/image1.png">
<h1>1</h1>
<img data-src="fake-url.png">
</section>
<section>
- <section>
+ <section data-background="examples/assets/image2.png">
<h1>2.1</h1>
</section>
<section>
diff --git a/test/test.js b/test/test.js
index 3bc934f..c0c25fb 100644
--- a/test/test.js
+++ b/test/test.js
@@ -114,11 +114,13 @@ Reveal.addEventListener( 'ready', function() {
});
test( 'Reveal.getSlideBackground', function() {
- var firstBackground = document.querySelector( '.reveal .backgrounds>.slide-background:first-child' );
+ equal( Reveal.getSlideBackground( 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ), 'gets correct first background' );
+ equal( Reveal.getSlideBackground( 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2)' ), 'no v index returns stack' );
+ equal( Reveal.getSlideBackground( 1, 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(1)' ), 'v index 0 returns first vertical child' );
+ equal( Reveal.getSlideBackground( 1, 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(2)' ), 'v index 1 returns second vertical child' );
- equal( Reveal.getSlideBackground( 0 ), firstBackground, 'gets correct first background' );
-
- strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'returns undefined when background can\'t be found' );
+ strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'undefined when out of horizontal bounds' );
+ strictEqual( Reveal.getSlideBackground( 1, 100 ), undefined, 'undefined when out of vertical bounds' );
});
test( 'Reveal.getPreviousSlide/getCurrentSlide', function() {
@@ -470,6 +472,15 @@ Reveal.addEventListener( 'ready', function() {
strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' );
});
+ test( 'background images', function() {
+ var imageSource1 = Reveal.getSlide( 0 ).getAttribute( 'data-background-image' );
+ var imageSource2 = Reveal.getSlide( 1, 0 ).getAttribute( 'data-background' );
+
+ // check that the images are applied to the background elements
+ ok( Reveal.getSlideBackground( 0 ).style.backgroundImage.indexOf( imageSource1 ) !== -1, 'data-background-image worked' );
+ ok( Reveal.getSlideBackground( 1, 0 ).style.backgroundImage.indexOf( imageSource2 ) !== -1, 'data-background worked' );
+ });
+
// ---------------------------------------------------------------
// EVENT TESTS