Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added tests for autoResolver

  • Loading branch information...
commit 0593988106cfcbc0c2de9062ab5559728e7a5f84 1 parent 246e75c
Ben Hockey authored August 16, 2011
8  all.js
@@ -18,15 +18,17 @@ define([
18 18
 	'./testKernel',
19 19
 	'./model/test',
20 20
 	'./lifecycle/test',
21  
-	'./factory/test'
  21
+	'./factory/test',
  22
+	'./autoResolver/test'
22 23
 ],
23  
-function (Twine, Kernel, Model, lifecycle, factory) {
  24
+function (Twine, Kernel, Model, lifecycle, factory, autoResolver) {
24 25
 	'use strict';
25 26
 	return {
26 27
 		'test Twine': Twine,
27 28
 		'test Kernel': Kernel,
28 29
 		'test Model': Model,
29 30
 		'test lifecycle': lifecycle,
30  
-		'test factory': factory
  31
+		'test factory': factory,
  32
+		'test auto resolver': autoResolver
31 33
 	};
32 34
 });
23  autoResolver/test.js
... ...
@@ -0,0 +1,23 @@
  1
+/**
  2
+ * @license Copyright (c) 2011 Cello Software, LLC.
  3
+ * All rights reserved.
  4
+ * Available via the new BSD License.
  5
+ */
  6
+/*jshint
  7
+	asi: false, bitwise: false, boss: false, curly: true, eqeqeq: true, eqnull: false, es5: true,
  8
+	evil: false, expr: true, forin: true, globalstrict: false, immed: true, indent: 4, latedef: true,
  9
+	laxbreak: false, loopfunc: true, maxlen: 100, newcap: true, noarg: true, noempty: true,
  10
+	nonew: true, nomen: false, onevar: true, passfail: false, plusplus: false, shadow: false,
  11
+	strict: false, sub: false, trailing: true, undef: true, white: true
  12
+*/
  13
+/*global define: false, require: false*/
  14
+
  15
+define([
  16
+	'./testFiber'
  17
+],
  18
+function (Fiber) {
  19
+	'use strict';
  20
+	return {
  21
+		'test Fiber': Fiber
  22
+	};
  23
+});
61  autoResolver/testFiber.js
... ...
@@ -0,0 +1,61 @@
  1
+/**
  2
+ * @license Copyright (c) 2011 Cello Software, LLC.
  3
+ * All rights reserved.
  4
+ * Available via the new BSD License.
  5
+ */
  6
+/*jshint
  7
+	asi: false, bitwise: false, boss: false, curly: true, eqeqeq: true, eqnull: false, es5: true,
  8
+	evil: false, expr: true, forin: true, globalstrict: false, immed: true, indent: 4, latedef: true,
  9
+	laxbreak: false, loopfunc: true, maxlen: 100, newcap: true, noarg: true, noempty: true,
  10
+	nonew: true, nomen: false, onevar: true, passfail: false, plusplus: false, shadow: false,
  11
+	strict: false, sub: false, trailing: true, undef: true, white: true
  12
+*/
  13
+/*global define: false, require: false*/
  14
+
  15
+define([
  16
+	'test/promiseTestCase',
  17
+	'assert',
  18
+	'twine/support/promise',
  19
+	'twine/autoResolver/Fiber'
  20
+], function (testCase, assert, promise, Fiber) {
  21
+	'use strict';
  22
+
  23
+	var when = promise.when;
  24
+
  25
+	return testCase({
  26
+		setUp: function () {
  27
+			this.kernel = {
  28
+				modelRegistry: {
  29
+					on: this.spy()
  30
+				}
  31
+			};
  32
+			this.model = {
  33
+				resolve: this.spy()
  34
+			};
  35
+			this.fiber = new Fiber();
  36
+		},
  37
+
  38
+		'test is a fiber': function () {
  39
+			assert.equal(typeof this.fiber.init, 'function');
  40
+			assert.equal(typeof this.fiber.terminate, 'function');
  41
+		},
  42
+
  43
+		'test listens to modelRegistry modelAdded event': function () {
  44
+			this.fiber.init(this.kernel);
  45
+			assert.ok(this.kernel.modelRegistry.on.calledWith('modelAdded'));
  46
+		},
  47
+
  48
+		'test listener resolves models with autoResolve: truthy': function () {
  49
+			this.fiber.init(this.kernel);
  50
+			var listener = this.kernel.modelRegistry.on.getCall(0).args[1];
  51
+
  52
+			this.model.autoResolve = false;
  53
+			listener(this.model);
  54
+			assert.ok(!this.model.resolve.called);
  55
+
  56
+			this.model.autoResolve = true;
  57
+			listener(this.model);
  58
+			assert.ok(this.model.resolve.called);
  59
+		}
  60
+	});
  61
+});
2  external/twine
... ...
@@ -1 +1 @@
1  
-Subproject commit eb90a16f03336bc2a2e1f9ac63fb87930a429db1
  1
+Subproject commit 8add326b469d224d199d51648c228b6bb1f9f814

0 notes on commit 0593988

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