Skip to content
Browse files

added message/InterceptorProxy tests

  • Loading branch information...
1 parent 5bfb1b6 commit c1adc9126d85dc094eba4bd480f5aa6c62c12413 @neonstalwart neonstalwart committed
Showing with 66 additions and 4 deletions.
  1. +1 −1 external/twine
  2. +5 −3 message/test.js
  3. +60 −0 message/testInterceptorProxy.js
2 external/twine
@@ -1 +1 @@
-Subproject commit 1bd3392bca8d8c5e062e5caf39d1dfe7d3402d54
+Subproject commit 737fa9d7a9f3ab97032867375d026eddb554a729
View
8 message/test.js
@@ -13,10 +13,12 @@
/*global define: false, require: false*/
define([
- './testFiber'
-], function (Fiber) {
+ './testFiber',
+ './testInterceptorProxy'
+], function (Fiber, InterceptorProxy) {
'use strict';
return {
- 'test Fiber': Fiber
+ 'test Fiber': Fiber,
+ 'test interceptor proxy': InterceptorProxy
};
});
View
60 message/testInterceptorProxy.js
@@ -0,0 +1,60 @@
+/**
+ * @license Copyright (c) 2011 Cello Software, LLC.
+ * All rights reserved.
+ * Available via the new BSD License.
+ */
+/*jshint
+ asi: false, bitwise: false, boss: false, curly: true, eqeqeq: true, eqnull: false, es5: true,
+ evil: false, expr: true, forin: true, globalstrict: false, immed: true, indent: 4, latedef: true,
+ laxbreak: false, loopfunc: true, maxlen: 100, newcap: true, noarg: true, noempty: true,
+ nonew: true, nomen: false, onevar: true, passfail: false, plusplus: false, shadow: false,
+ strict: false, sub: false, trailing: true, undef: true, white: true
+*/
+/*global define: false, require: false*/
+
+define([
+ 'test/promiseTestCase',
+ 'assert',
+ 'twine/support/promise',
+ 'twine/message/InterceptorProxy'
+], function (testCase, assert, promise, InterceptorProxy) {
+ 'use strict';
+
+ var when = promise.when;
+
+ return testCase({
+ setUp: function () {
+ },
+
+ 'test is an interceptor': function () {
+ var interceptor = new InterceptorProxy();
+
+ assert.equal(typeof interceptor.intercept, 'function');
+ },
+
+ 'test resolves component from model, calls intercept and releases component': function () {
+ var component = {
+ intercept: this.spy()
+ },
+ model = {
+ resolve: this.spy(function () {
+ // mock promise
+ return {
+ then: function (cb) {
+ cb(component);
+ }
+ };
+ }),
+ release: this.spy()
+ },
+ interceptor = new InterceptorProxy(model),
+ obj = {},
+ str = 'string';
+
+ interceptor.intercept(obj, str);
+ assert.ok(model.resolve.called);
+ assert.ok(component.intercept.calledWith(obj, str));
+ assert.ok(model.release.calledWith(component));
+ }
+ });
+});

0 comments on commit c1adc91

Please sign in to comment.
Something went wrong with that request. Please try again.