<commit_before>module('jQuery The Final Countdown');

// Helpers
var $dom;

QUnit.testStart(function() {
    $dom = $('<div id="clock" />').appendTo('body');
});

QUnit.testDone(function() {
    try{
        $dom.countdown('remove');
    } catch(e) {
        $dom.remove();
    }
});

module('Sanity tests');

test('ensure DOM for testing is created', function() {
    var node = document.getElementById($dom.attr('id'));
    ok(node !== null);
    ok(node !== undefined);
    ok($dom.length === 1);
});

test('countdown method exists within jquery selector', function() {
    ok($.fn.countdown !== undefined);
    ok($.fn.countdown !== null);
    ok($.fn.countdown);
});

test('throws an error when initiated with wrong number of arguments', function() {
    throws(function() {
        $('<div />').countdown();
    });
});

module('Events');

asyncTest('trigger the update event', 1, function() {
    $dom.countdown('2020/10/20').on('update.countdown', function(event) {
        ok(true); // Up to this point the event was dispatched
        start();
    });
});

asyncTest('trigger the finish event', 1, function() {
    $dom.countdown('2010/10/20').on('finish.countdown', function(event) {
        ok(true); // Up to this point the event was dispatched
        start();
    });
});

asyncTest('event object has {finalDate, offset, offsetDate, strftime} properties', function() {
    expect(4);

    $dom.countdown('2020/10/20').on('update.countdown', function(event) {
        ok(event.hasOwnProperty('finalDate'));
        ok(event.hasOwnProperty('offset'));
        ok(event.hasOwnProperty('offsetDate'));
        ok(event.hasOwnProperty('strftime'));
        start();
    });
});

asyncTest('event.offset object has {seconds, minutes, hours, days, totalDays, weeks, years} properties', function() {
    expect(7);

    $dom.countdown('2020/10/20').on('update.countdown', function(event) {
        ok(event.offset.hasOwnProperty('seconds'));
        ok(event.offset.hasOwnProperty('minutes'));
        ok(event.offset.hasOwnProperty('hours'));
        ok(event.offset.hasOwnProperty('days'));
        ok(event.offset.hasOwnProperty('totalDays'));
        ok(event.offset.hasOwnProperty('weeks'));
        ok(event.offset.hasOwnProperty('years'));
        start();
    });
});

asyncTest('allow the callback be setted uppon initialization (legacy style)', 1, function() {
    $dom.countdown('2020/10/20', function(event) {
        ok(true); // Up to this point the event was dispatched
        start();
    });
});

module('Commands and functionality');

asyncTest('stop/start the countdown', 2, function() {
    var callback = sinon.spy();
    $dom.countdown('2020/10/20').on('update.countdown', callback);
    // Stop after 0.51 sec
    setTimeout(function() {
        $dom.countdown('stop');
    }, 510);
    // Resume after 1 sec
    setTimeout(function() {<commit_msg>Change the legacy test from async<commit_after>module('jQuery The Final Countdown');

// Helpers
var $dom;

QUnit.testStart(function() {
    $dom = $('<div id="clock" />').appendTo('body');
});

QUnit.testDone(function() {
    try{
        $dom.countdown('remove');
    } catch(e) {
        $dom.remove();
    }
});

module('Sanity tests');

test('ensure DOM for testing is created', function() {
    var node = document.getElementById($dom.attr('id'));
    ok(node !== null);
    ok(node !== undefined);
    ok($dom.length === 1);
});

test('countdown method exists within jquery selector', function() {
    ok($.fn.countdown !== undefined);
    ok($.fn.countdown !== null);
    ok($.fn.countdown);
});

test('throws an error when initiated with wrong number of arguments', function() {
    throws(function() {
        $('<div />').countdown();
    });
});

module('Events');

asyncTest('trigger the update event', 1, function() {
    $dom.countdown('2020/10/20').on('update.countdown', function(event) {
        ok(true); // Up to this point the event was dispatched
        start();
    });
});

asyncTest('trigger the finish event', 1, function() {
    $dom.countdown('2010/10/20').on('finish.countdown', function(event) {
        ok(true); // Up to this point the event was dispatched
        start();
    });
});

asyncTest('event object has {finalDate, offset, offsetDate, strftime} properties', function() {
    expect(4);

    $dom.countdown('2020/10/20').on('update.countdown', function(event) {
        ok(event.hasOwnProperty('finalDate'));
        ok(event.hasOwnProperty('offset'));
        ok(event.hasOwnProperty('offsetDate'));
        ok(event.hasOwnProperty('strftime'));
        start();
    });
});

asyncTest('event.offset object has {seconds, minutes, hours, days, totalDays, weeks, years} properties', function() {
    expect(7);

    $dom.countdown('2020/10/20').on('update.countdown', function(event) {
        ok(event.offset.hasOwnProperty('seconds'));
        ok(event.offset.hasOwnProperty('minutes'));
        ok(event.offset.hasOwnProperty('hours'));
        ok(event.offset.hasOwnProperty('days'));
        ok(event.offset.hasOwnProperty('totalDays'));
        ok(event.offset.hasOwnProperty('weeks'));
        ok(event.offset.hasOwnProperty('years'));
        start();
    });
});

test('allow the callback be setted uppon initialization (legacy style)', function() {
    $dom.countdown('2020/10/20', function(event) {
        ok(true); // Up to this point the event was dispatched
    });
});

module('Commands and functionality');

asyncTest('stop/start the countdown', 2, function() {
    var callback = sinon.spy();
    $dom.countdown('2020/10/20').on('update.countdown', callback);
    // Stop after 0.51 sec
    setTimeout(function() {
        $dom.countdown('stop');
    }, 510);
    // Resume after 1 sec
    setTimeout(function() {
{'fraction_non_alphanumeric': 0.18425169476794717, 'fraction_numerical': 0.021380149487224057, 'mean_word_length': 3.4604651162790696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '624400', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1714, 'n_words': 375}