From 6901615670afeca02698af3d84ec8b48135a81bc Mon Sep 17 00:00:00 2001 From: Nathaniel Higgins Date: Sat, 6 Apr 2013 04:47:12 +0100 Subject: [PATCH] Add failing tests for custom jquery events. --- test/jq-list_test.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/jq-list_test.js b/test/jq-list_test.js index 606b869..1fa5d87 100644 --- a/test/jq-list_test.js +++ b/test/jq-list_test.js @@ -164,6 +164,29 @@ equal($element.find('> li:first-child > input').val(), fourth, 'Fourth val'); equal($element.find('> li:first-child [data-sublist]').children().length, 1, 'child length after delete'); equal($element.find('> li:first-child [data-sublist]').children().eq(0).find('input').val(), fifth, 'Fifth val after delete'); + }, + + 'events are triggered': { + test: function($element) { + + + var timer = setTimeout(function() { + start(); + ok(false, 'It failed'); + }, 1000); + + $element.on('list-add', function() { + clearTimeout(timer); + ok(true, 'Event triggered'); + equal(arguments.length, 2, 'Argument length is correct'); + equal(arguments[1], 0, 'Index is correct'); + + start(); + }); + + $element.find('> li > .buttons [data-role=add]').click(); + }, + func: asyncTest } }; @@ -197,7 +220,7 @@ test_obj.func(name, function() { runList(); Array.prototype.unshift.call(arguments, $element); - test_func.apply(this, arguments); + test_obj.test.apply(this, arguments); $element.list('reset'); });