Skip to content

Commit

Permalink
Added some jasmine tests, place jasmine in test/lib/ and run specRunn…
Browse files Browse the repository at this point in the history
…er.html
  • Loading branch information
mdix committed Feb 26, 2012
1 parent e43cead commit 5b8d5bf
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/specRunner.html
@@ -0,0 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner: Jasmine Testproject</title>
<link rel="shortcut icon" type="image/png" href="lib/images/jasmine_favicon.png">
<link href="lib/lib/jasmine-core/jasmine.css" rel="stylesheet"/>
<!-- OWN SOURCES -->
<script type="text/javascript" src="../iframe.js"></script>
<!-- JASMINE SOURCES -->
<script type="text/javascript" src="lib/lib/jasmine-core/jasmine.js"></script>
<script type="text/javascript" src="lib/src/html/TrivialReporter.js"></script>
<script type="text/javascript" src="lib/src/console/ConsoleReporter.js"></script>
<!-- OWN SPECS -->
<script type="text/javascript" src="testIframe.js"></script>
<!-- INITIATES JASMINE -->
<script type="text/javascript">
(function(){function d(){a.execute()}var a=jasmine.getEnv();a.updateInterval=1e3;var b=new jasmine.TrivialReporter;a.addReporter(b);a.specFilter=function(a){return b.specFilter(a)};var c=window.onload;window.onload=function(){if(c){c()}d()}})()
</script>
</head>
<body>
</body>
</html>
48 changes: 48 additions & 0 deletions test/testIframe.js
@@ -0,0 +1,48 @@
describe('YtIframe instantiated with a string', function() {
var videoHash = 'w4yGJEU85wY';
var iframe = YtIframe(videoHash);

it('returns an IFRAME node object', function() {
expect(iframe.nodeName).toEqual('IFRAME');
});

it('which has a width property', function() {
expect(iframe.hasAttribute('width')).toBeTruthy();
});

it('where with is the default value of 560', function() {
expect(iframe.width).toEqual('560');
});

it('which has a height property', function() {
expect(iframe.hasAttribute('height')).toBeTruthy();
});

it('where height is the default value of 315', function() {
expect(iframe.height).toEqual('315');
});

it('which has a src property', function() {
expect(iframe.hasAttribute('src')).toBeTruthy();
});

it('that contains the youtube embed link and the passed video hash', function() {
expect(iframe.src).toMatch('http://www.youtube.com/embed/' + videoHash);
})

it('which has a frameBorder property', function() {
expect(iframe.hasAttribute('frameBorder')).toBeTruthy();
});

it('that is set to 0', function() {
expect(iframe.frameBorder).toEqual('0');
});

it('which has a allowFullScreen property', function() {
expect(iframe.hasAttribute('allowFullScreen')).toBeTruthy();
});

it('that is a empty string', function() {
expect(iframe.getAttribute('allowFullScreen')).toEqual("");
});
})

0 comments on commit 5b8d5bf

Please sign in to comment.