Sha256: 70747feaf5e4a4e43692c444ea401a7d2725241d7ef168464c2d4a7d18a53237
Contents?: true
Size: 1.69 KB
Versions: 41
Compression:
Stored size: 1.69 KB
Contents
// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2011 Strobe Inc. and contributors. // ©2008-2011 Apple Inc. All rights reserved. // License: Licensed under MIT license (see license.js) // ========================================================================== // ======================================================================== // SC.TaskQueue Base Tests // ======================================================================== /*globals module test ok isObj equals expects */ var taskQueue; module("Task Queue",{ setup: function(){ taskQueue = SC.TaskQueue.create(); } }); test("Adding a task should not cause it to run.",function(){ var task = SC.Task.create({ run: function(){ this.ran = YES; } }); taskQueue.push(task); ok(!task.ran, "Task should not have run"); }); test("Adding a task and calling run() should cause the task to be run.",function(){ var task = SC.Task.create({ run: function(){ this.ran = YES; } }); taskQueue.push(task); taskQueue.run(); ok(task.ran, "Task should have run"); }); test("Adding multiple tasks and calling run should run the tasks in order.",function(){ var ri = 0; var task = SC.Task.extend({ run: function(){ this.ran = ri++; } }), t1, t2, t3, t4; taskQueue.push(t1 = task.create()); taskQueue.push(t2 = task.create()); taskQueue.push(t3 = task.create()); taskQueue.push(t4 = task.create()); taskQueue.run(); equals(t1.ran, 0, "Task 1 should be first"); equals(t2.ran, 1, "Task 1 should be second"); equals(t3.ran, 2, "Task 1 should be third"); equals(t4.ran, 3, "Task 1 should be fourth"); });
Version data entries
41 entries across 41 versions & 1 rubygems