Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'integration-yuitest'

  • Loading branch information...
commit 9777a6a884eee31e971202dab8c9b3ceb81f33a4 2 parents 569c6c0 + 1aafe1c
@keronsen keronsen authored
View
71 docs/examples/yuitest/example.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
+<title>YUI Test results</title>
+
+<link rel="stylesheet" type="text/css" href="lib/yuitest.css">
+<script type="text/javascript" src="lib/yuitest.js"></script>
+
+<script type="text/javascript" src="../../../src/jack.js"></script>
+
+</head>
+<body>
+ <script type="text/javascript">
+
+ /** START SPECIFYING FUNCTIONS THAT TESTS RUN AGAINST **/
+ function myGlobalFunction() {
+ return "This is myGlobalFunction()";
+ }
+
+ window.myGlobalObject = {}
+ window.myGlobalObject.functionOne = function() {
+ return "This is myGlobalObject.functionOne()";
+ }
+ /** END SPECIFYING FUNCTIONS THAT TESTS RUN AGAINST **/
+
+ var successfulTestCase = new YAHOO.tool.TestCase({
+
+ name: "Examples of successful expectations",
+
+ testExpectedFunctionIsCalled : function () {
+ jack(function(){
+ jack.expect("myGlobalFunction");
+ myGlobalFunction();
+ });
+ },
+
+ testExpectedFunctionIsCalledOnObject : function () {
+ jack(function(){
+ jack.expect("myGlobalObject.functionOne");
+ myGlobalObject.functionOne();
+ });
+ }
+ });
+
+ var failingTestCase = new YAHOO.tool.TestCase({
+
+ name: "Examples of failing expectations",
+
+ testExpectedFunctionIsNotCalled : function () {
+ jack(function(){
+ jack.expect("myGlobalFunction");
+ });
+ },
+
+ testExpectedFunctionIsNotCalledOnObject : function () {
+ jack(function(){
+ jack.expect("myGlobalObject.functionOne");
+ });
+ }
+ });
+
+ var logger = new YAHOO.tool.TestLogger();
+
+ YAHOO.tool.TestRunner.add(successfulTestCase);
+ YAHOO.tool.TestRunner.add(failingTestCase);
+ YAHOO.tool.TestRunner.run();
+
+ </script>
+</body>
+</html>
View
14 docs/examples/yuitest/lib/yuitest.css
@@ -0,0 +1,14 @@
+/*
+Copyright (c) 2009, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.8.0r4
+*/
+.yui-skin-sam .yui-log{padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000;}.yui-skin-sam .yui-log-container{position:absolute;top:1em;right:1em;}.yui-skin-sam .yui-log input{margin:0;padding:0;font-family:arial;font-size:100%;font-weight:normal;}.yui-skin-sam .yui-log .yui-log-btns{position:relative;float:right;bottom:.25em;}.yui-skin-sam .yui-log .yui-log-hd{margin-top:1em;padding:.5em;background-color:#575757;}.yui-skin-sam .yui-log .yui-log-hd h4{margin:0;padding:0;font-size:108%;font-weight:bold;color:#FFF;}.yui-skin-sam .yui-log .yui-log-bd{width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}.yui-skin-sam .yui-log p{margin:1px;padding:.1em;}.yui-skin-sam .yui-log pre{margin:0;padding:0;}.yui-skin-sam .yui-log pre.yui-log-verbose{white-space:pre-wrap;white-space:-moz-pre-wrap!important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;}.yui-skin-sam .yui-log .yui-log-ft{margin-top:.5em;}.yui-skin-sam .yui-log .yui-log-ft .yui-log-sourcefilters{width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}.yui-skin-sam .yui-log .yui-log-filtergrp{margin-right:.5em;}.yui-skin-sam .yui-log .info{background-color:#A7CC25;}.yui-skin-sam .yui-log .warn{background-color:#F58516;}.yui-skin-sam .yui-log .error{background-color:#E32F0B;}.yui-skin-sam .yui-log .time{background-color:#A6C9D7;}.yui-skin-sam .yui-log .window{background-color:#F2E886;}
+/*
+Copyright (c) 2009, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.8.0r4
+*/
+
View
10,252 docs/examples/yuitest/lib/yuitest.js
10,252 additions, 0 deletions not shown
View
9 src/jack.js
@@ -452,6 +452,7 @@ function jack() {} // This needs to be here to make error reporting work correct
'isScriptaculous': isScriptaculous,
'isQunit': isQunit,
'isJsTestDriver': isJsTestDriver,
+ 'isYuiTest': isYuiTest,
'report': report,
'disableReporting': function() { reportingEnabled = false; },
'enableReporting': function() { reportingEnabled = true; },
@@ -472,9 +473,15 @@ function jack() {} // This needs to be here to make error reporting work correct
function isJsTestDriver() {
return window.jstestdriver != null;
}
+ function isYuiTest() {
+ var y = window.YAHOO;
+ return y != null && y.tool != null && y.tool.TestCase != null;
+ }
function report(message) {
if(!reportingEnabled) { return; }
- if(isJsTestDriver()) {
+ if(isYuiTest()) {
+ YAHOO.util.Assert.fail(message);
+ } else if(isJsTestDriver()) {
fail(message);
} else if(isScriptaculous()) {
throw new Error(message);
View
42 test/test_84_integration_yuitest.js
@@ -0,0 +1,42 @@
+
+
+describe('Integration with YUI Test',{
+ after_each: function() {
+ window.YAHOO = null;
+ }
+ ,
+ 'Should know when YUI Test is in environment': function() {
+ window.YAHOO = { tool: { TestCase: function() {} } };
+ value_of(jack.env.isYuiTest()).should_be_true();
+ }
+ ,
+ 'Should know when YUI Test not is in environment': function() {
+ value_of(jack.env.isYuiTest()).should_be_false();
+ }
+ ,
+ 'Should report unmet expectations by calling YAHOO.util.Assert.fail(message)': function() {
+ var actualMessage = "";
+ var called = 0;
+ window.YAHOO = {
+ tool: {
+ TestCase: function() {} 
+ },
+ util: {
+ Assert: {
+ fail: function(message) {
+ called++;
+ actualMessage = message;
+ } 
+ }
+ }
+ };
+
+ window.globalFunction = function() {};
+ jack(function(){
+ jack.expect("globalFunction").once();
+ });
+
+ value_of(called).should_be(1);
+ value_of(actualMessage).should_be("Expectation failed: globalFunction() expected exactly 1 time, called 0 times");
+ }
+});
View
1  test/test_all.html
@@ -27,6 +27,7 @@
<script type="text/javascript" src="test_81_integration_scriptaculous.js"></script>
<script type="text/javascript" src="test_82_integration_qunit.js"></script>
<script type="text/javascript" src="test_83_integration_jstestdriver.js"></script>
+<script type="text/javascript" src="test_84_integration_yuitest.js"></script>
<script type="text/javascript" src="test_99_bugfix.js"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.