<commit_before>// Configured in Gruntfile.js
var url = 'http://localhost:4242/index.html';

casper.test.begin('The app should load flawlessly', 1, function suite(test) {
    casper.start(url, function() {
        test.assertHttpStatus(200,'http status is 200');
    });

    casper.run(function() {
        test.done();
    });
});

casper.test.begin('Start pomodoro button', function(test) {
    casper.start(url, function() {
        // Wait for requirejs to load all scripts
        this.wait(100);
    });

    casper.then(function() {
        test.assertSelectorHasText('#timer', '00:00');
    });

    casper.then(function() {
        this.click('#start-pomodoro-btn');
        test.assertSelectorHasText('#timer', '25:00');

        this.wait(1000);
        test.assertSelectorHasText('#timer', '24:59');

        this.wait(1000);
        test.assertSelectorHasText('#timer', '24:58');
    });

    casper.run(function() {
        test.done();
    });
});

casper.test.begin('Button activations', function(test) {
    casper.start(url, function() {
        // Wait for requirejs to load all scripts
        this.wait(100);
    });

    casper.then(function() {
        test.assertEqual(
            this.getElementAttribute('#start-pomodoro-btn', 'disabled'),
            false
        );
        test.assertEqual(
            this.getElementAttribute('#start-break-btn', 'disabled'),
            false
        );
        test.assertEqual(
            this.getElementAttribute('#start-lbreak-btn', 'disabled'),
            false
        );
        test.assertEqual(
            this.getElementAttribute('#stop-btn', 'disabled'),
            true
        );
    });

    casper.then(function() {
        this.click('#start-pomodoro-btn');

        test.assertEqual(
            this.getElementAttribute('#start-pomodoro-btn', 'disabled'),
            true
        );
        test.assertEqual(
            this.getElementAttribute('#start-break-btn', 'disabled'),
            true
        );
        test.assertEqual(
            this.getElementAttribute('#start-lbreak-btn', 'disabled'),
            true
        );
        test.assertEqual(
            this.getElementAttribute('#stop-btn', 'disabled'),
            false
        );
    });

    casper.then(function() {
        this.click('#stop-btn');

        test.assertEqual(
            this.getElementAttribute('#start-pomodoro-btn', 'disabled'),
            false
        );
        test.assertEqual(
            this.getElementAttribute('#start-break-btn', 'disabled'),
            false
        );
        test.assertEqual(
            this.getElementAttribute('#start-lbreak-btn', 'disabled'),
            false
        );
        test.assertEqual(
            this.getElementAttribute('#stop-btn', 'disabled'),
            true
        );
    });
});<commit_msg>Testing buttons activation / deactivation<commit_after>// Configured in Gruntfile.js
var url = 'http://localhost:4242/index.html';

//casper.on('remote.message', function(message) {
//    casper.debug('>>> ' + message);
//});


casper.isDisabled = function(selector) {
    "use strict";
    this.checkStarted();
    return this.evaluate(function _evaluate(selector) {
        var element = __utils__.findOne(selector);
        return element.hasAttribute('disabled');
    }, selector);
};

casper.test.begin('The app should load flawlessly', 1, function suite(test) {
    casper.start(url, function() {
        test.assertHttpStatus(200,'http status is 200');
    });

    casper.run(function() {
        test.done();
    });
});

casper.test.begin('Start pomodoro button', function(test) {
    casper.start(url, function() {
        // Wait for requirejs to load all scripts
        this.wait(100);
    });

    casper.then(function() {
        test.assertSelectorHasText('#timer', '00:00');
    });

    casper.then(function() {
        this.click('#start-pomodoro-btn');
        test.assertSelectorHasText('#timer', '25:00');
    });

    casper.wait(1010, function() {
        test.assertSelectorHasText('#timer', '24:59');
    });

    casper.wait(1010, function() {
        test.assertSelectorHasText('#timer', '24:58');
    });

    casper.run(function() {
        test.done();
    });
});

casper.test.begin('Button activations', function(test) {
    casper.start(url, function() {
        // Wait for requirejs to load all scripts
        this.wait(100);
    });

    casper.then(function() {
        test.assertFalsy(casper.isDisabled('#start-pomodoro-btn'));
        test.assertFalsy(casper.isDisabled('#start-break-btn'));
        test.assertFalsy(casper.isDisabled('#start-lbreak-btn'));
        test.assert(casper.isDisabled('#stop-btn'));
    });

    casper.then(function() {
        this.click('#start-pomodoro-btn');
        test.assert(casper.isDisabled('#start-pomodoro-btn'));
        test.assert(casper.isDisabled('#start-break-btn'));
        test.assert(casper.isDisabled('#start-lbreak-btn'));
        test.assertFalsy(casper.isDisabled('#stop-btn'));
    });

    casper.then(function() {
        this.click('#stop-btn');
        test.assertFalsy(casper.isDisabled('#start-pomodoro-btn'));
        test.assertFalsy(casper.isDisabled('#start-break-btn'));
        test.assertFalsy(casper.isDisabled('#start-lbreak-btn'));
        test.assert(casper.isDisabled('#stop-btn'));
    });

    casper.run(function() {
        test.done();
    });
});
{'fraction_non_alphanumeric': 0.1661111111111111, 'fraction_numerical': 0.015185185185185185, 'mean_word_length': 2.4097222222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7446799', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1563, 'n_words': 225}