Permalink
Browse files

added tests for autoResolver

  • Loading branch information...
1 parent 246e75c commit 0593988106cfcbc0c2de9062ab5559728e7a5f84 @neonstalwart neonstalwart committed Aug 16, 2011
Showing with 90 additions and 4 deletions.
  1. +5 −3 all.js
  2. +23 −0 autoResolver/test.js
  3. +61 −0 autoResolver/testFiber.js
  4. +1 −1 external/twine
View
@@ -18,15 +18,17 @@ define([
'./testKernel',
'./model/test',
'./lifecycle/test',
- './factory/test'
+ './factory/test',
+ './autoResolver/test'
],
-function (Twine, Kernel, Model, lifecycle, factory) {
+function (Twine, Kernel, Model, lifecycle, factory, autoResolver) {
'use strict';
return {
'test Twine': Twine,
'test Kernel': Kernel,
'test Model': Model,
'test lifecycle': lifecycle,
- 'test factory': factory
+ 'test factory': factory,
+ 'test auto resolver': autoResolver
};
});
View
@@ -0,0 +1,23 @@
+/**
+ * @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([
+ './testFiber'
+],
+function (Fiber) {
+ 'use strict';
+ return {
+ 'test Fiber': Fiber
+ };
+});
@@ -0,0 +1,61 @@
+/**
+ * @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/autoResolver/Fiber'
+], function (testCase, assert, promise, Fiber) {
+ 'use strict';
+
+ var when = promise.when;
+
+ return testCase({
+ setUp: function () {
+ this.kernel = {
+ modelRegistry: {
+ on: this.spy()
+ }
+ };
+ this.model = {
+ resolve: this.spy()
+ };
+ this.fiber = new Fiber();
+ },
+
+ 'test is a fiber': function () {
+ assert.equal(typeof this.fiber.init, 'function');
+ assert.equal(typeof this.fiber.terminate, 'function');
+ },
+
+ 'test listens to modelRegistry modelAdded event': function () {
+ this.fiber.init(this.kernel);
+ assert.ok(this.kernel.modelRegistry.on.calledWith('modelAdded'));
+ },
+
+ 'test listener resolves models with autoResolve: truthy': function () {
+ this.fiber.init(this.kernel);
+ var listener = this.kernel.modelRegistry.on.getCall(0).args[1];
+
+ this.model.autoResolve = false;
+ listener(this.model);
+ assert.ok(!this.model.resolve.called);
+
+ this.model.autoResolve = true;
+ listener(this.model);
+ assert.ok(this.model.resolve.called);
+ }
+ });
+});
Submodule twine updated 1 files
+5 −2 autoResolver/Fiber.js

0 comments on commit 0593988

Please sign in to comment.