Author: erinnp
Date: Fri Jun 28 19:49:56 2013
New Revision: 1497901
URL: http://svn.apache.org/r1497901
Log:
update tests from dan and rohit
Added:
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_event_manager.spec
Modified:
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_api.spec
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_state_manager.spec
rave/branches/require/rave-portal-resources/src/test/javascript/rave_core_spec.js
Modified:
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_api.spec
URL:
http://svn.apache.org/viewvc/rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_api.spec?rev=1497901&r1=1497900&r2=1497901&view=diff
==============================================================================
---
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_api.spec
(original)
+++
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_api.spec
Fri Jun 28 19:49:56 2013
@@ -23,15 +23,6 @@ var mock = {
}
}
-var eventManager = {
- registerOnInitHandler: function(){}
-}
-
-var stateManager = {
- getContext: function(){}
-}
-
-
describe('rave_api', function(){
@@ -43,9 +34,9 @@ describe('rave_api', function(){
spyOn(mock, 'ajax').andCallThrough();
api = testr('core/rave_api', {
- './rave_ajax': mock.ajax,
- './rave_state_manager': stateManager,
- './rave_event_manager': eventManager
+ 'core/rave_ajax': mock.ajax,
+ 'core/rave_state_manager': {getContext: function(){}},
+ 'core/rave_event_manager': {registerOnInitHandler: function(){}}
})
spyOn(testScope, 'callback');
});
Added:
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_event_manager.spec
URL:
http://svn.apache.org/viewvc/rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_event_manager.spec?rev=1497901&view=auto
==============================================================================
---
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_event_manager.spec
(added)
+++
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_event_manager.spec
Fri Jun 28 19:49:56 2013
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+describe('rave_event_manager', function(){
+ beforeEach(function () {
+ eventManager = testr('core/rave_event_manager');
+
+ });
+
+ describe('regsiterOnInitHandler', function(){
+
+ it('throws an error if handler is not a function', function () {
+ expect(function () {
+ eventManager.registerOnInitHandler({})
+ }).toThrow();
+ });
+
+ it('registers a handler that is fired on init in the order
registered', function () {
+ var arr = [];
+
+ eventManager.registerOnInitHandler(function () {
+ arr.push(1);
+ });
+ eventManager.registerOnInitHandler(function () {
+ arr.push(2);
+ });
+ expect(arr).toEqual([]);
+ eventManager.init();
+ expect(arr).toEqual([1, 2]);
+ });
+
+ it('immediately invokes a handler if rave.init has already been
called', function () {
+ var scope = {
+ handler: function () {
+ }
+ };
+
+ spyOn(scope, 'handler');
+
+ eventManager.init();
+ expect(scope.handler).not.toHaveBeenCalled();
+ eventManager.registerOnInitHandler(scope.handler);
+ expect(scope.handler).toHaveBeenCalled();
+ });
+ })
+})
Modified:
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_state_manager.spec
URL:
http://svn.apache.org/viewvc/rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_state_manager.spec?rev=1497901&r1=1497900&r2=1497901&view=diff
==============================================================================
---
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_state_manager.spec
(original)
+++
rave/branches/require/rave-portal-resources/src/test/javascript/core/rave_state_manager.spec
Fri Jun 28 19:49:56 2013
@@ -226,6 +226,30 @@ describe('state_manager', function(){
expect(stateManager.getDefaultView.mostRecentCall.args.length).toEqual(0)
})
})
+
+ describe('set javascript debug mode', function(){
+ it('sets the java script debug mode correctly', function(){
+ spyOn(stateManager, 'setDebugMode').andCallThrough();
+
+ stateManager.setDebugMode(true);
+
+ expect(stateManager.getDebugMode()).toBe(true);
+ expect(stateManager.setDebugMode).toHaveBeenCalled();
+
expect(stateManager.setDebugMode.mostRecentCall.args[0]).toEqual(true)
+ })
+ })
+
+ describe('get javascript debug mode', function(){
+ it('gets the javascript debug mode correctly', function(){
+ spyOn(stateManager, 'getDebugMode').andCallThrough();
+
+ var output = stateManager.getDebugMode();
+
+ expect(output).toBe(false);
+ expect(stateManager.getDebugMode).toHaveBeenCalled()
+
expect(stateManager.getDebugMode.mostRecentCall.args.length).toEqual(0)
+ })
+ })
})
Modified:
rave/branches/require/rave-portal-resources/src/test/javascript/rave_core_spec.js
URL:
http://svn.apache.org/viewvc/rave/branches/require/rave-portal-resources/src/test/javascript/rave_core_spec.js?rev=1497901&r1=1497900&r2=1497901&view=diff
==============================================================================
---
rave/branches/require/rave-portal-resources/src/test/javascript/rave_core_spec.js
(original)
+++
rave/branches/require/rave-portal-resources/src/test/javascript/rave_core_spec.js
Fri Jun 28 19:49:56 2013
@@ -1,5 +1,4 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
+/* * 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
@@ -15,7 +14,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *//*
+ */
describe('rave', function () {
@@ -27,10 +26,8 @@ describe('rave', function () {
viewObject,
testScope = {};
- */
-/*
setup mock objects to be used in tests
- *//*
+
beforeEach(function () {
provider = {
@@ -394,4 +391,4 @@ describe('rave', function () {
expect(scope.handler).toHaveBeenCalled();
});
});
-});*/
+});