<commit_before>/*
======== A Handy Little QUnit Reference ========
  http://api.qunitjs.com/

  Test methods:
    module(name, {[beforeEach][, afterEach]})
    test(name, callback)
  Test assertions:
    expect(numberOfAssertions)
    async()
    ok(value, [message])
    notOk(value, [message])
    equal(actual, expected, [message])
    notEqual(actual, expected, [message])
    deepEqual(actual, expected, [message])
    notDeepEqual(actual, expected, [message])
    strictEqual(actual, expected, [message])
    notStrictEqual(actual, expected, [message])
    throws(block, [expected], [message])
*/

(function (window, document, QUnit, $, sinon) {

    QUnit.module('basics', {
        beforeEach: function() {
            this.elems = $('#qunit-fixture').children();
        }
    });

    QUnit.test('is chainable', function (assert) {
        assert.expect(1);
        // Not a bad test to run on collection methods.
        assert.strictEqual(this.elems.formDialog(), this.elems, 'should be chainable');
    });

    QUnit.module('global dialog options', {
        beforeEach: function () {
            this.elem = $('<div><form></form></div>');
        },
        afterEach: function () {
            this.elem.remove();
        }
    });

    QUnit.test('autoOpen: true', function (assert) {
        assert.expect(1);

        this.elem.formDialog({ autoOpen: true });
        assert.ok(this.elem.dialog("widget").is(":visible"), 'dialog should be open by default');
    });

    QUnit.test('autoOpen: false', function (assert) {
        assert.expect(1);

        this.elem.formDialog({ autoOpen: false });
        assert.notOk(this.elem.dialog("widget").is(":visible"), 'dialog should not be open by default');
    });

    QUnit.test('autoOpen: default', function (assert) {
        assert.expect(1);

        this.elem.formDialog();
        assert.notOk(this.elem.dialog("widget").is(":visible"), 'dialog should not be open by default');
    });

    QUnit.test('width', function (assert) {
        assert.expect(1);

        this.elem.formDialog({ autoOpen: true });
        assert.close(this.elem.dialog("widget").width(), 500, 1, 'default width should be 500px');
   });

    QUnit.module('buttons', {
        beforeEach: function () {
            this.elem = $('<div><form></form></div>');
        },
        afterEach: function () {
            this.elem.remove();
        }
    });

    QUnit.test('button properties', function (assert) {
        var btn;
        assert.expect(3);

        this.elem.formDialog();
        btn = this.elem.dialog('widget').find('.ui-dialog-buttonpane button');
        
        assert.equal(btn.length, 2, 'dialog should have 2 buttons');
        assert.equal(btn.eq(0).text(), 'Save', 'submit button should be named "Save"');
        assert.equal(btn.eq(1).text(), 'Cancel', 'abort button should be named "Cancel"');
    });

    QUnit.test('custom button label', function (assert) {
        var btn;
        assert.expect(1);

        this.elem.formDialog({ actionLabel: 'FizzBuzz' });
        btn = this.elem.dialog('widget').find('.ui-dialog-buttonpane button');
        
        assert.equal(btn.eq(0).text(), 'FizzBuzz', 'submit button should have custom label');
    });

    QUnit.test('translate button label', function (assert) {
        var btn;
        assert.expect(2);

        this.elem.formDialog({ language: 'de' });
        btn = this.elem.dialog('widget').find('.ui-dialog-buttonpane button');
        
        assert.equal(btn.eq(0).text(), 'Speichern', 'submit button label should be translated');
        assert.equal(btn.eq(1).text(), 'Abbrechen', 'abort button label should be translated');
    });

    QUnit.test('cancel button', function (assert) {
        var btn;
        assert.expect(2);<commit_msg>added no button test<commit_after>/*
======== A Handy Little QUnit Reference ========
  http://api.qunitjs.com/

  Test methods:
    module(name, {[beforeEach][, afterEach]})
    test(name, callback)
  Test assertions:
    expect(numberOfAssertions)
    async()
    ok(value, [message])
    notOk(value, [message])
    equal(actual, expected, [message])
    notEqual(actual, expected, [message])
    deepEqual(actual, expected, [message])
    notDeepEqual(actual, expected, [message])
    strictEqual(actual, expected, [message])
    notStrictEqual(actual, expected, [message])
    throws(block, [expected], [message])
*/

(function (window, document, QUnit, $, sinon) {

    QUnit.module('basics', {
        beforeEach: function() {
            this.elems = $('#qunit-fixture').children();
        }
    });

    QUnit.test('is chainable', function (assert) {
        assert.expect(1);
        // Not a bad test to run on collection methods.
        assert.strictEqual(this.elems.formDialog(), this.elems, 'should be chainable');
    });

    QUnit.module('global dialog options', {
        beforeEach: function () {
            this.elem = $('<div><form></form></div>');
        },
        afterEach: function () {
            this.elem.remove();
        }
    });

    QUnit.test('autoOpen: true', function (assert) {
        assert.expect(1);

        this.elem.formDialog({ autoOpen: true });
        assert.ok(this.elem.dialog("widget").is(":visible"), 'dialog should be open by default');
    });

    QUnit.test('autoOpen: false', function (assert) {
        assert.expect(1);

        this.elem.formDialog({ autoOpen: false });
        assert.notOk(this.elem.dialog("widget").is(":visible"), 'dialog should not be open by default');
    });

    QUnit.test('autoOpen: default', function (assert) {
        assert.expect(1);

        this.elem.formDialog();
        assert.notOk(this.elem.dialog("widget").is(":visible"), 'dialog should not be open by default');
    });

    QUnit.test('width', function (assert) {
        assert.expect(1);

        this.elem.formDialog({ autoOpen: true });
        assert.close(this.elem.dialog("widget").width(), 500, 1, 'default width should be 500px');
   });

    QUnit.module('buttons', {
        beforeEach: function () {
            this.elem = $('<div><form></form></div>');
        },
        afterEach: function () {
            this.elem.remove();
        }
    });

    QUnit.test('default buttons', function (assert) {
        var btn;
        assert.expect(3);

        this.elem.formDialog();
        btn = this.elem.dialog('widget').find('.ui-dialog-buttonpane button');
        
        assert.equal(btn.length, 2, 'dialog should have 2 buttons');
        assert.equal(btn.eq(0).text(), 'Save', 'submit button should be named "Save"');
        assert.equal(btn.eq(1).text(), 'Cancel', 'abort button should be named "Cancel"');
    });

    QUnit.test('no form no buttons', function (assert) {
        var btn, elem;
        assert.expect(1);

        elem = $('<div></div>').formDialog();
        btn = elem.dialog('widget').find('.ui-dialog-buttonpane button');

        assert.strictEqual(btn.length, 0, 'should have no buttons');
        elem.remove();
    });

    QUnit.test('custom button label', function (assert) {
        var btn;
        assert.expect(1);

        this.elem.formDialog({ actionLabel: 'FizzBuzz' });
        btn = this.elem.dialog('widget').find('.ui-dialog-buttonpane button');
        
        assert.equal(btn.eq(0).text(), 'FizzBuzz', 'submit button should have custom label');
    });

    QUnit.test('translate button label', function (assert) {
        var btn;
        assert.expect(2);

        this.elem.formDialog({ language: 'de' });
        btn = this.elem.dialog('widget').find('.ui-dialog-buttonpane button');
        
        assert.equal(btn.eq(0).text(), 'Speichern', 'submit button label should be translated');
        assert.equal(btn.eq(1).text(), 'Abbrechen', 'abort button label should be translated');
    });

    QUnit.test('cancel button', function (assert) {
        var btn;
        assert.expect(2);
{'fraction_non_alphanumeric': 0.17189873417721518, 'fraction_numerical': 0.0060759493670886075, 'mean_word_length': 2.669763121226196, 'pattern_counts': {'":': 6, '<': 21, '<?xml version=': 0, '>': 21, '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': '5579333', 'n_tokens_mistral': 2369, 'n_tokens_neox': 2306, 'n_words': 510}