<commit_before>'use strict';

const assert = require('assert'),
      loader = require('../../mongooseloader.js');

module.exports = {
    exists: async () => {
        return loader.hasOwnProperty('loadSchema');
    },
    isFunction: async () => {
        return typeof loader.loadSchema === 'function';
    },
    throwsErrorOnNonJSFile: async () => {
        try {
            await loader.loadSchema('test.png');
            assert.fail('No error thrown');
        } catch (err) {
            assert.equal(err.message, 'file is not a javascript file');
        }
    },
    throwsErrorOnAlreadyExistingSchema: async () => {
        try {
            loader.setSchemaSource('./test/loadschema/throwserroronalreadyexistingschema');
            await loader.loadSchema('MyDocument.js');
            await loader.loadSchema('MyDocument.js');
        } catch (err) {
            assert.equal(err.message, 'a schema already exists with name MyDocument');
        }
    },
    throwsErrorOnNonSchemaJavascriptFile: async () => {
        try {
            loader.setSchemaSource('./test/loadschema/throwserroronnonschemajavascriptfile');
            await loader.loadSchema('MyInvalidDocument.js');
        } catch (err) {
            assert.equal(err.message, 'given schema is not a schema');
        }
    },
    loadValidSchemasIntoMongoose: async () => {
        loader.setSchemaSource('./test/loadschema/loadvalidschemasintomongoose');
        await loader.loadSchema('MyValidDocument.js');
    },
    loadsRequiredSchemasBeforeActualSchema: async() => {
        loader.setSchemaSource('./test/loadschema/loadsrequiredschemasbeforeactualschema');
        let schemas = await loader.loadSchema('MyDependingSchema.js');

        assert.ok(schemas['MyDependingSchema']);
        assert.ok(schemas['TheRequiredSchema']);
    }
};<commit_msg>typo<commit_after>'use strict';

const assert = require('assert'),
      loader = require('../../mongooseloader.js');

module.exports = {
    exists: async () => {
        return loader.hasOwnProperty('loadSchema');
    },
    isFunction: async () => {
        return typeof loader.loadSchema === 'function';
    },
    throwsErrorOnNonJSFile: async () => {
        try {
            await loader.loadSchema('test.png');
            assert.fail('No error thrown');
        } catch (err) {
            assert.equal(err.message, 'file is not a javascript file');
        }
    },
    throwsErrorOnAlreadyExistingSchema: async () => {
        try {
            loader.setSchemaSource('./test/loadSchema/throwserroronalreadyexistingschema');
            await loader.loadSchema('MyDocument.js');
            await loader.loadSchema('MyDocument.js');
        } catch (err) {
            assert.equal(err.message, 'a schema already exists with name MyDocument');
        }
    },
    throwsErrorOnNonSchemaJavascriptFile: async () => {
        try {
            loader.setSchemaSource('./test/loadSchema/throwserroronnonschemajavascriptfile');
            await loader.loadSchema('MyInvalidDocument.js');
        } catch (err) {
            assert.equal(err.message, 'given schema is not a schema');
        }
    },
    loadValidSchemasIntoMongoose: async () => {
        loader.setSchemaSource('./test/loadSchema/loadvalidschemasintomongoose');
        await loader.loadSchema('MyValidDocument.js');
    },
    loadsRequiredSchemasBeforeActualSchema: async() => {
        loader.setSchemaSource('./test/loadSchema/loadsrequiredschemasbeforeactualschema');
        let schemas = await loader.loadSchema('MyDependingSchema.js');

        assert.ok(schemas['MyDependingSchema']);
        assert.ok(schemas['TheRequiredSchema']);
    }
};
{'fraction_non_alphanumeric': 0.13355137639683837, 'fraction_numerical': 0.0, 'mean_word_length': 2.6736736736736737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3933607', 'n_tokens_mistral': 994, 'n_tokens_neox': 987, 'n_words': 164}