<commit_before>/* eslint-disable @typescript-eslint/no-non-null-assertion */
import MongoMemoryReplSet, {
  MongoMemoryReplSetEvents,
  MongoMemoryReplSetStates,
} from '../MongoMemoryReplSet';
import { MongoClient } from 'mongodb';
import MongoMemoryServer from '../MongoMemoryServer';
import * as utils from '../util/utils';
import { MongoMemoryInstanceOpts } from '../util/MongoInstance';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000;

afterEach(() => {
  jest.restoreAllMocks();
});

describe('single server replset', () => {
  it('should enter running state', async () => {
    const replSet = await MongoMemoryReplSet.create();
    expect(replSet.getUri().split(',').length).toEqual(1);

    await replSet.stop();
  });

  it('"getUri" should be able to get connection string to specific db', async () => {
    const replSet = await MongoMemoryReplSet.create();
    const uri = replSet.getUri('other');
    expect(uri.split(',').length).toEqual(1);
    expect(uri.includes('/other')).toBeTruthy();
    expect(uri.includes('replicaSet=testset')).toBeTruthy();

    await replSet.stop();
  });

  it('"getUri" should be able to generate an dbName', async () => {
    jest.spyOn(utils, 'generateDbName');
    const replSet = await MongoMemoryReplSet.create();<commit_msg>test(MongoMemoryReplSet): lower the timeout<commit_after>/* eslint-disable @typescript-eslint/no-non-null-assertion */
import MongoMemoryReplSet, {
  MongoMemoryReplSetEvents,
  MongoMemoryReplSetStates,
} from '../MongoMemoryReplSet';
import { MongoClient } from 'mongodb';
import MongoMemoryServer from '../MongoMemoryServer';
import * as utils from '../util/utils';
import { MongoMemoryInstanceOpts } from '../util/MongoInstance';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;

afterEach(() => {
  jest.restoreAllMocks();
});

describe('single server replset', () => {
  it('should enter running state', async () => {
    const replSet = await MongoMemoryReplSet.create();
    expect(replSet.getUri().split(',').length).toEqual(1);

    await replSet.stop();
  });

  it('"getUri" should be able to get connection string to specific db', async () => {
    const replSet = await MongoMemoryReplSet.create();
    const uri = replSet.getUri('other');
    expect(uri.split(',').length).toEqual(1);
    expect(uri.includes('/other')).toBeTruthy();
    expect(uri.includes('replicaSet=testset')).toBeTruthy();

    await replSet.stop();
  });

  it('"getUri" should be able to generate an dbName', async () => {
    jest.spyOn(utils, 'generateDbName');
    const replSet = await MongoMemoryReplSet.create();
{'fraction_non_alphanumeric': 0.16045066045066045, 'fraction_numerical': 0.006216006216006216, 'mean_word_length': 4.722222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3143119', 'n_tokens_mistral': 826, 'n_tokens_neox': 806, 'n_words': 170}