dwf/rva: Added examples, fixed bug with initializing currentSuite with a mock.

This commit is contained in:
pivotal 2008-12-03 17:11:05 -08:00
parent e025755a61
commit 00f5f1722c
7 changed files with 113 additions and 24 deletions

24
example/example.html Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Tests</title>
<script type="text/javascript" src="../lib/jasmine.js"></script>
<script type="text/javascript" src="example.js"></script>
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
</head>
<body>
<h1>
Running Jasmine Example Specs
</h1>
<div id="results"></div>
<script type="text/javascript">
Jasmine.execute();
setTimeout(function () {
document.getElementById('results').innerHTML = 'It\'s alive! :' + (Jasmine.results.passedCount ==1);
}, 250);
</script>
</body>
</html>

7
example/example.js Normal file
View File

@ -0,0 +1,7 @@
describe('one suite description', function () {
it('should be a test', function() {
runs(function () {
this.expects_that(true).should_equal(true);
});
});
});

View File

@ -80,7 +80,7 @@
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html"> <entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678"> <state line="7" column="61" selection-start="350" selection-end="350" vertical-scroll-proportion="0.13782384">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -89,19 +89,10 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="bootstrap.js" pinned="false" current="true" current-in-tab="true"> <file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js"> <entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="642" column="7" selection-start="18504" selection-end="18504" vertical-scroll-proportion="0.81150794"> <state line="518" column="0" selection-start="14460" selection-end="14460" vertical-scroll-proportion="0.59381044">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="test.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/test.css">
<provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -110,7 +101,37 @@
<file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js"> <entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="284" column="31" selection-start="5933" selection-end="5933" vertical-scroll-proportion="0.85083413"> <state line="279" column="17" selection-start="5820" selection-end="5820" vertical-scroll-proportion="0.3968254">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="example.html" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider selected="true" editor-type-id="text-editor">
<state line="18" column="6" selection-start="620" selection-end="620" vertical-scroll-proportion="0.35440415">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="jasmine.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/jasmine.css">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="8" selection-start="315" selection-end="315" vertical-scroll-proportion="0.29400387">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="example.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/example.js">
<provider selected="true" editor-type-id="text-editor">
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11025145">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -224,6 +245,24 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:/Users/pivotal/workspace/jasmine/example" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</component> </component>
<component name="ProjectReloadState"> <component name="ProjectReloadState">
@ -379,7 +418,7 @@
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.21091811" order="0" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.21091811" order="0" />
<window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> <window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32841328" order="1" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32841328" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
@ -461,7 +500,7 @@
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html"> <entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="15" column="26" selection-start="541" selection-end="541" vertical-scroll-proportion="0.29533678"> <state line="7" column="61" selection-start="350" selection-end="350" vertical-scroll-proportion="0.13782384">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -469,27 +508,44 @@
<state /> <state />
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/test.css"> <entry file="file://$PROJECT_DIR$/lib/jasmine.css">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="5" column="0" selection-start="118" selection-end="118" vertical-scroll-proportion="0.09187621"> <state line="16" column="8" selection-start="315" selection-end="315" vertical-scroll-proportion="0.29400387">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js"> <entry file="file://$PROJECT_DIR$/example/example.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="284" column="31" selection-start="5933" selection-end="5933" vertical-scroll-proportion="0.85083413"> <state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11025145">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js"> <entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="642" column="7" selection-start="18504" selection-end="18504" vertical-scroll-proportion="0.81150794"> <state line="518" column="0" selection-start="14460" selection-end="14460" vertical-scroll-proportion="0.59381044">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="279" column="17" selection-start="5820" selection-end="5820" vertical-scroll-proportion="0.3968254">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider selected="true" editor-type-id="text-editor">
<state line="18" column="6" selection-start="620" selection-end="620" vertical-scroll-proportion="0.35440415">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
</component> </component>
</project> </project>

2
test/test.css → lib/jasmine.css Executable file → Normal file
View File

@ -15,7 +15,7 @@ p {
} }
p.fail { p.fail {
background: url(../images/exclamation.png) no-repeat; background: url( ../images/exclamation.png ) no-repeat;
color: red; color: red;
} }

View File

@ -277,7 +277,7 @@ var Runner = function () {
} }
var Jasmine = Runner(); var Jasmine = Runner();
var currentSuite = describe('default current suite', function() {}); var currentSuite;
var currentSpec; var currentSpec;
/* /*

View File

@ -5,7 +5,7 @@
<title>Jasmine Tests</title> <title>Jasmine Tests</title>
<script type="text/javascript" src="prototype-1.6.0.3.js"></script> <script type="text/javascript" src="prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="../lib/jasmine.js"></script> <script type="text/javascript" src="../lib/jasmine.js"></script>
<link type="text/css" rel="stylesheet" href="test.css"/> <link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
<script type="text/javascript" src="bootstrap.js"></script> <script type="text/javascript" src="bootstrap.js"></script>
</head> </head>
<body onLoad="runTests();"> <body onLoad="runTests();">

4
test/bootstrap.js vendored
View File

@ -91,6 +91,8 @@ var testMatchersReporting = function () {
} }
var testSpecs = function () { var testSpecs = function () {
var currentSuite = describe('default current suite', function() {});
var spec = it('new spec'); var spec = it('new spec');
reporter.test((spec.description == 'new spec'), reporter.test((spec.description == 'new spec'),
"Spec did not have a description"); "Spec did not have a description");
@ -508,7 +510,7 @@ var testRunner = function() {
it('should be a test'); it('should be a test');
}); });
reporter.test((runner.suites.length === 2), reporter.test((runner.suites.length === 2),
"Runner expected two suites"); "Runner expected two suites, but got " + runner.suites.length);
runner = Runner(); runner = Runner();
describe('one suite description', function () { describe('one suite description', function () {