<commit_before>define([
    'settings/js/widgets/database-widget',
    'test/server-widget-test-utils',
    'jasmine-jquery'
], function(DatabaseWidget, serverUtils) {

    describe('Database widget', function(initialConfig) {
        function testDatabaseCheckbox() {
            it('should use the username for the database name when the checkbox is checked', function() {
                var $checkbox = this.widget.$('input[type="checkbox"]');
                var $username = this.widget.$('input[name="username"]');
                var $database = this.widget.$('input[name="database"]');

                this.widget.updateConfig(_.defaults({
                    username: 'postgres',
                    database: 'postgres'
                }, initialConfig));

                expect($checkbox).toHaveProp('checked', true);
                expect($username).toHaveValue('postgres');
                expect($database).toHaveValue('postgres');

                $checkbox.prop('checked', false).trigger('change');
                $username.val('myUser').trigger('change');
                $database.val('siteadmin').trigger('change');

                expect($username).toHaveValue('myUser');
                expect($database).toHaveValue('siteadmin');

                $checkbox.prop('checked', true).trigger('change');

                expect($username).toHaveValue('myUser');
                expect($database).toHaveValue('myUser');
            });

            //TODO: write test
            it('should fail client side validation on empty database', function() {
                var $database = this.widget.$('input[name="database"]');
                $database.val('');

                expect()
            });
        }

        describe('when it has an enabled widget', function() {
            var initialConfig = {<commit_msg>Fill in missing test. [rev: matthew.gordon]<commit_after>define([
    'settings/js/widgets/database-widget',
    'test/server-widget-test-utils',
    'jasmine-jquery'
], function(DatabaseWidget, serverUtils) {

    describe('Database widget', function(initialConfig) {
        function testDatabaseCheckbox() {
            it('should use the username for the database name when the checkbox is checked', function() {
                var $checkbox = this.widget.$('input[type="checkbox"]');
                var $username = this.widget.$('input[name="username"]');
                var $database = this.widget.$('input[name="database"]');

                this.widget.updateConfig(_.defaults({
                    username: 'postgres',
                    database: 'postgres'
                }, initialConfig));

                expect($checkbox).toHaveProp('checked', true);
                expect($username).toHaveValue('postgres');
                expect($database).toHaveValue('postgres');

                $checkbox.prop('checked', false).trigger('change');
                $username.val('myUser').trigger('change');
                $database.val('siteadmin').trigger('change');

                expect($username).toHaveValue('myUser');
                expect($database).toHaveValue('siteadmin');

                $checkbox.prop('checked', true).trigger('change');

                expect($username).toHaveValue('myUser');
                expect($database).toHaveValue('myUser');
            });

            it('should fail client side validation on empty database', function() {
                var $database = this.widget.$('input[name="database"]');
                $database.val('');

                expect(this.widget.validateInputs()).toBe(false);
            });
        }

        describe('when it has an enabled widget', function() {
            var initialConfig = {
{'fraction_non_alphanumeric': 0.14876476906552094, 'fraction_numerical': 0.0, 'mean_word_length': 2.1197654941373534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3211087', 'n_tokens_mistral': 924, 'n_tokens_neox': 857, 'n_words': 162}