<commit_before>/* eslint-disable no-unused-expressions */
const expect = require('chai').expect;
const sinon = require('sinon');
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

const expectedFiles = require('./utils/expected-files');
const Base = require('../generators/generator-base');
const { testInTempDir, revertTempDir } = require('./utils/utils');
const { parseLiquibaseChangelogDate } = require('../utils/liquibase');

const BaseGenerator = Base.prototype;

BaseGenerator.log = msg => {
    // eslint-disable-next-line no-console
    console.log(msg);
};

const fakeGenerator = custom => {
    return {
        debug: sinon.spy(),
        warning: sinon.spy(),
        copy: sinon.spy(),
        processJs: sinon.spy(),
        processHtml: sinon.spy(),
        template: sinon.spy(),
        templatePath: sinon.stub().callsFake((...dest) => path.join(...dest)),
        ...custom,
    };
};

describe('Generator Base', () => {
    describe('getAllSupportedLanguages', () => {
        describe('when called', () => {
            it('returns an array', () => {
                expect(BaseGenerator.getAllSupportedLanguages()).to.not.have.length(0);
            });
        });
    });
    describe('isSupportedLanguage', () => {
        describe('when called with valid language', () => {
            it('returns true', () => {
                expect(BaseGenerator.isSupportedLanguage('en')).to.equal(true);
            });
        });
        describe('when called with invalid language', () => {
            it('returns false', () => {
                expect(BaseGenerator.isSupportedLanguage('ab')).to.equal(false);
            });
        });
    });
    describe('getAllSupportedLanguageOptions', () => {
        describe('when called', () => {
            it('returns an array', () => {
                expect(BaseGenerator.getAllSupportedLanguages()).to.not.have.length(0);
            });
        });
    });
    describe('getTableName', () => {
        describe('when called with a value', () => {
            it('returns a table name', () => {
                expect(BaseGenerator.getTableName('tableName')).to.equal('table_name');
            });
        });
    });
    describe('getColumnName', () => {
        describe('when called with a value', () => {
            it('returns a column name', () => {
                expect(BaseGenerator.getColumnName('colName')).to.equal('col_name');
                expect(BaseGenerator.getColumnName('colNName')).to.equal('colnname');
            });
        });
    });
    describe('getJoinTableName', () => {
        describe('when called with a value', () => {
            it('returns a join table name', () => {
                expect(BaseGenerator.getJoinTableName('entityName', 'relationshipName', 'postgresql')).to.equal(
                    'rel_entity_name__relationship_name'
                );
            });
        });
        describe('when called with a long name', () => {
            it('returns a proper join table name', () => {
                expect(BaseGenerator.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.equal(
                    'rel_entity_name_l__relation_be'
                );
                expect(BaseGenerator.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.have.length(30);
            });
        });
        describe('when legacyRelationshipTableName is set', () => {
            it('returns a proper join table name', () => {
                function TestClass() {}
                TestClass.prototype = Object.create(Base.prototype);
                TestClass.prototype.jhipsterConfig = { legacyRelationshipTableName: true };
                expect(TestClass.prototype.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.equal(
                    'entity_name_lon_relationship_n'
                );
                expect(TestClass.prototype.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.have.length(30);<commit_msg>Missing fix<commit_after>/* eslint-disable no-unused-expressions */
const expect = require('chai').expect;
const sinon = require('sinon');
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

const expectedFiles = require('./utils/expected-files');
const Base = require('../generators/generator-base');
const { testInTempDir, revertTempDir } = require('./utils/utils');
const { parseLiquibaseChangelogDate } = require('../utils/liquibase');

const BaseGenerator = Base.prototype;

BaseGenerator.log = msg => {
    // eslint-disable-next-line no-console
    console.log(msg);
};

const fakeGenerator = custom => {
    return {
        debug: sinon.spy(),
        warning: sinon.spy(),
        copy: sinon.spy(),
        processJs: sinon.spy(),
        processHtml: sinon.spy(),
        template: sinon.spy(),
        templatePath: sinon.stub().callsFake((...dest) => path.join(...dest)),
        ...custom,
    };
};

describe('Generator Base', () => {
    describe('getAllSupportedLanguages', () => {
        describe('when called', () => {
            it('returns an array', () => {
                expect(BaseGenerator.getAllSupportedLanguages()).to.not.have.length(0);
            });
        });
    });
    describe('isSupportedLanguage', () => {
        describe('when called with valid language', () => {
            it('returns true', () => {
                expect(BaseGenerator.isSupportedLanguage('en')).to.equal(true);
            });
        });
        describe('when called with invalid language', () => {
            it('returns false', () => {
                expect(BaseGenerator.isSupportedLanguage('ab')).to.equal(false);
            });
        });
    });
    describe('getAllSupportedLanguageOptions', () => {
        describe('when called', () => {
            it('returns an array', () => {
                expect(BaseGenerator.getAllSupportedLanguages()).to.not.have.length(0);
            });
        });
    });
    describe('getTableName', () => {
        describe('when called with a value', () => {
            it('returns a table name', () => {
                expect(BaseGenerator.getTableName('tableName')).to.equal('table_name');
            });
        });
    });
    describe('getColumnName', () => {
        describe('when called with a value', () => {
            it('returns a column name', () => {
                expect(BaseGenerator.getColumnName('colName')).to.equal('col_name');
                expect(BaseGenerator.getColumnName('colNName')).to.equal('colnname');
            });
        });
    });
    describe('getJoinTableName', () => {
        describe('when called with a value', () => {
            it('returns a join table name', () => {
                expect(BaseGenerator.getJoinTableName('entityName', 'relationshipName', 'postgresql')).to.equal(
                    'rel_entity_name__relationship_name'
                );
            });
        });
        describe('when called with a long name', () => {
            it('returns a proper join table name', () => {
                expect(BaseGenerator.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.equal(
                    'rel_entity_name_l__relation_be'
                );
                expect(BaseGenerator.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.have.length(30);
            });
        });
        describe('when legacyRelationshipTableName is set', () => {
            it('returns a proper join table name', () => {
                function TestClass() {}
                TestClass.prototype = Object.create(Base.prototype);
                TestClass.prototype.jhipsterConfig = { legacyRelationshipTableName: true };
                expect(TestClass.prototype.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.equal(
                    'rel_entity_name_l__relation_be'
                );
                expect(TestClass.prototype.getJoinTableName('entityNameLonger', 'relationshipName', 'oracle')).to.have.length(30);
{'fraction_non_alphanumeric': 0.16384596517046848, 'fraction_numerical': 0.0014716703458425313, 'mean_word_length': 2.3394758394758393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 59, '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': '6316051', 'n_tokens_mistral': 2189, 'n_tokens_neox': 2139, 'n_words': 346}