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

Version Path
sproutcore-1.11.0 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.11.0.rc3 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.11.0.rc2 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.11.0.rc1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.3.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.2 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.0 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/task_queue.js