From 2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 18 Oct 2022 08:59:09 +0200 Subject: Update --- alarm/node_modules/node-forge/tests/tasks.js | 378 +++++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 alarm/node_modules/node-forge/tests/tasks.js (limited to 'alarm/node_modules/node-forge/tests/tasks.js') diff --git a/alarm/node_modules/node-forge/tests/tasks.js b/alarm/node_modules/node-forge/tests/tasks.js new file mode 100644 index 0000000..dd3ffde --- /dev/null +++ b/alarm/node_modules/node-forge/tests/tasks.js @@ -0,0 +1,378 @@ +/** + * Forge Tasks Test + * + * @author David I. Lehn + * + * Copyright (c) 2009-2010 Digital Bazaar, Inc. All rights reserved. + */ +jQuery(function($) +{ + var cat = 'forge.tests.tasks'; + + var tests = []; + var passed = 0; + var failed = 0; + + var init = function() { + passed = failed = 0; + $('.ready,.testing,.pass,.fail') + .removeClass('ready testing pass fail'); + $('#status') + .text('Ready.') + .addClass('ready'); + $('#total').text(tests.length); + $('#pass').text(passed); + $('#fail').text(failed); + $('.expect').empty(); + $('.result').empty(); + $('.time').empty(); + $('#start').removeAttr('disabled'); + }; + + var start = function() + { + $('#start').attr('disabled', 'disabled'); + // meta! use tasks to run the task tests + forge.task.start({ + type: 'test', + run: function(task) { + task.next('starting', function(task) { + forge.log.debug(cat, 'start'); + $('#status') + .text('Testing...') + .addClass('testing') + .removeClass('idle'); + }); + $.each(tests, function(i, test) { + task.next('test', function(task) { + var title = $('li:first', test.container); + if($('#scroll:checked').length === 1) + { + $('html,body').animate({scrollTop: title.offset().top}); + } + title.addClass('testing'); + test.run(task, test); + }); + task.next('test', function(task) { + $('li:first', test.container).removeClass('testing'); + }); + }); + task.next('success', function(task) { + forge.log.debug(cat, 'done'); + if(failed === 0) { + $('#status') + .text('PASS') + .addClass('pass') + .removeClass('testing'); + } else { + // FIXME: should just be hitting failure() below + $('#status') + .text('FAIL') + .addClass('fail') + .removeClass('testing'); + } + }); + }, + failure: function() { + $('#status') + .text('FAIL') + .addClass('fail') + .removeClass('testing'); + } + }); + }; + + $('#start').click(function() { + start(); + }); + + $('#reset').click(function() { + init(); + }); + + var addTest = function(name, run) + { + var container = $('