<commit_before>import {UserSchema, IUserModel} from "../../src/server/data/User";
import {GameSchema, IGameModel} from "../../src/server/data/GameModel";
import mongoose from "mongoose";
import assert from "assert";

const connectionString = "mongodb://localhost/test"
const User = mongoose.model("User", UserSchema) as IUserModel;
const GameModel = mongoose.model("GameModel", GameSchema) as IGameModel;

describe("User", () => {
    beforeEach(async () => {
        await mongoose.connect(connectionString);
        await mongoose.connection.db.dropDatabase()
    });

    afterEach(async () => {
        await mongoose.disconnect()
    })

    describe("findOrCreate", () => {
        it("should create user", async () => {
            await User.findOrCreate("M4T4L4");

            const users = await User.find().exec();
            assert.equal(1, users.length, "users");
        });
    });

    describe("addGame", () => {
        it("should add game for logged in user", async () => {<commit_msg>Fix url parser warning during tests<commit_after>import {UserSchema, IUserModel} from "../../src/server/data/User";
import {GameSchema, IGameModel} from "../../src/server/data/GameModel";
import mongoose from "mongoose";
import assert from "assert";

const connectionString = "mongodb://localhost:27017/test"
const User = mongoose.model("User", UserSchema) as IUserModel;
const GameModel = mongoose.model("GameModel", GameSchema) as IGameModel;

describe("User", () => {
    beforeEach(async () => {
        await mongoose.connect(connectionString, {useNewUrlParser: true});
        await mongoose.connection.db.dropDatabase()
    });

    afterEach(async () => {
        await mongoose.disconnect()
    })

    describe("findOrCreate", () => {
        it("should create user", async () => {
            await User.findOrCreate("M4T4L4");

            const users = await User.find().exec();
            assert.equal(1, users.length, "users");
        });
    });

    describe("addGame", () => {
        it("should add game for logged in user", async () => {
{'fraction_non_alphanumeric': 0.162227602905569, 'fraction_numerical': 0.006295399515738499, 'mean_word_length': 3.1653225806451615, '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': '2322443', 'n_tokens_mistral': 596, 'n_tokens_neox': 606, 'n_words': 137}