From dc66687149078876f3964a5ab0b9aa0434f46cdc Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 5 Nov 2010 15:05:24 -0700
Subject: added tests for documentation
---
docs/validator.template | 1 +
docs/widget.template | 1 +
docs/wiki_widgets.js | 2 +-
src/validators.js | 30 +++++++++++++++++++++++-------
src/widgets.js | 23 +++++++++++++++++++++++
5 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/docs/validator.template b/docs/validator.template
index 0d1a04f2..517a2fa0 100644
--- a/docs/validator.template
+++ b/docs/validator.template
@@ -22,6 +22,7 @@
Example
{{{exampleDescription}}}
+
{{{example}}}
\ No newline at end of file
diff --git a/docs/widget.template b/docs/widget.template
index b26bfb1c..f07bd9b2 100644
--- a/docs/widget.template
+++ b/docs/widget.template
@@ -20,6 +20,7 @@
{{name}}:{{#type}}{{type}}{{/type}}{{^type}}:*{{/type}}{{#default}}={{default}}{{/default}} : {{{description}}}
{{/param}}
+{{{paramDescription}}}
CSS
{{{css}}}
diff --git a/docs/wiki_widgets.js b/docs/wiki_widgets.js
index 0147536b..771d3f8c 100644
--- a/docs/wiki_widgets.js
+++ b/docs/wiki_widgets.js
@@ -20,7 +20,7 @@
'<angular/> ' +
'plain ' +
'source ' +
- '' + html + ' ' +
+ '' + html + ' ' +
'' + html + ' ' +
' ' +
'');
diff --git a/src/validators.js b/src/validators.js
index a1543f41..2d8b5354 100644
--- a/src/validators.js
+++ b/src/validators.js
@@ -116,29 +116,45 @@ extend(angularValidator, {
*
* * `data`: data object as passed from validate function
*
- * @css ng-input-indicator-wait
+ * @css ng-input-indicator-wait, ng-validation-error
*
* @exampleDescription
*
- * function myValidator (value, callback) {
+ * function myValidator (inputToValidate, validationDone) {
* // simulate delayed response, validate on even input length
* setTimeout(function(){
- * callback(value.length % 2);
- * }, 2000);
+ * validationDone(inputToValidate.length % 2);
+ * }, 500);
* };
*
*
* @example
*
* This input is validated asynchronously:
*
*
+ * @scenario
+ * it('should change color in delayed way', function(){
+ * var textBox = element('.example :input');
+ * expect(textBox.attr('className')).not().toMatch(/ng-input-indicator-wait/);
+ * expect(textBox.attr('className')).not().toMatch(/ng-validation-error/);
+ *
+ * input('text').enter('X');
+ * expect(textBox.attr('className')).toMatch(/ng-input-indicator-wait/);
+ *
+ * pause(.6);
+ *
+ * expect(textBox.attr('className')).not().toMatch(/ng-input-indicator-wait/);
+ * expect(textBox.attr('className')).toMatch(/ng-validation-error/);
+ *
+ * });
+ *
*/
/*
* cache is attached to the element
diff --git a/src/widgets.js b/src/widgets.js
index 7a06fd6c..4845e694 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -268,6 +268,17 @@ angularWidget('option', function(){
*
*
* @scenario
+ * it('should load date filter', function(){
+ * expect(element('.example ng\\:include').text()).toMatch(/angular\.filter\.date/);
+ * });
+ * it('should change to hmtl filter', function(){
+ * select('url').option('angular.filter.html.html');
+ * expect(element('.example ng\\:include').text()).toMatch(/angular\.filter\.html/);
+ * });
+ * it('should change to blank', function(){
+ * select('url').option('(blank)');
+ * expect(element('.example ng\\:include').text()).toEqual('');
+ * });
*/
angularWidget('ng:include', function(element){
var compiler = this,
@@ -328,6 +339,11 @@ angularWidget('ng:include', function(element){
* ...
*
* @param {*} on expression to match against ng:switch-when .
+ * @paramDescription
+ * On child elments add:
+ *
+ * * `ng:switch-when`: the case statement to match against. If match then this
+ * case will be displayed.
*
* @example
@@ -343,6 +359,13 @@ angularWidget('ng:include', function(element){
*
* @scenario
+ * it('should start in settings', function(){
+ * expect(element('.example ng\\:switch').text()).toEqual('Settings Div');
+ * });
+ * it('should change to home', function(){
+ * select('switch').option('home');
+ * expect(element('.example ng\\:switch').text()).toEqual('Home Span');
+ * });
*/
var ngSwitch = angularWidget('ng:switch', function (element){
var compiler = this,
--
cgit v1.2.3