You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2013/08/27 19:36:39 UTC

svn commit: r1517893 - /incubator/climate/trunk/rcmet/src/main/ui/test/unit/directives/OnBlur.js

Author: joyce
Date: Tue Aug 27 17:36:38 2013
New Revision: 1517893

URL: http://svn.apache.org/r1517893
Log:
CLIMATE-280 - Add test for OnBlur

- Add unit test to check that on-blur calls the function passed to it
  when a 'blur' event is triggered.

Added:
    incubator/climate/trunk/rcmet/src/main/ui/test/unit/directives/OnBlur.js

Added: incubator/climate/trunk/rcmet/src/main/ui/test/unit/directives/OnBlur.js
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/test/unit/directives/OnBlur.js?rev=1517893&view=auto
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/test/unit/directives/OnBlur.js (added)
+++ incubator/climate/trunk/rcmet/src/main/ui/test/unit/directives/OnBlur.js Tue Aug 27 17:36:38 2013
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+**/
+
+'use strict';
+
+describe('directives', function() {
+	beforeEach(module('ocw'));
+
+	describe('onBlur directive', function() {
+		it('should call the supplied function on the blur event', function() {
+			inject(function($compile, $rootScope) {
+				// Set a rootScope variable to make sure that on-blur calls 
+				// the function that we pass to it.
+				$rootScope.bogusFunction = function() {
+					$rootScope.test = "hi"
+				}
+
+				var element = $compile('<input on-blur="bogusFunction();" />')($rootScope);
+
+				expect($rootScope.test).toNotBe('hi');
+				element.trigger('blur');
+				expect($rootScope.test).toBe('hi');
+			});
+		});
+	});
+});