<commit_before>/*
 * Copyright (C) 2017 TypeFox and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */

import 'mocha';
import * as chai from 'chai';
import * as path from 'path';
import { FileSearchServiceImpl } from './file-search-service-impl';
import { FileUri } from '@theia/core/lib/node';
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';

const expect = chai.expect;

describe('search-service', () => {
    it('shall fuzzy search this spec file', async () => {
        const service = new FileSearchServiceImpl(new MockLogger());
        const uri = FileUri.create(path.resolve(__dirname, ".."));
        const matches = await service.find(uri.toString(), 'spc');
        const expectedFile = FileUri.create(__filename).toString();
        const testFile = matches.find(e => e.endsWith(expectedFile));
        expect(testFile).to.eql(FileUri.create(__filename).toString());
    });

    it('shall respect nested .gitignore', async () => {
        const service = new FileSearchServiceImpl(new MockLogger());
        const uri = FileUri.create(path.resolve(__dirname, "../../test-resources"));
        const matches = await service.find(uri.toString(), 'foo', { fuzzyMatch: false });

        expect(matches.some(e => e.endsWith('test-resources/foo.txt'))).eq(false);
        expect(matches.some(e => e.endsWith('test-resources/subdir1/sub-bar/foo.txt'))).eq(false);
        expect(matches.some(e => e.endsWith('test-resources/subdir1/sub2/foo.txt'))).eq(true);<commit_msg>Increase file-search-service-impl.spec timeout to 10secs<commit_after>/*
 * Copyright (C) 2017 TypeFox and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */

import 'mocha';
import * as chai from 'chai';
import * as path from 'path';
import { FileSearchServiceImpl } from './file-search-service-impl';
import { FileUri } from '@theia/core/lib/node';
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';

const expect = chai.expect;

describe('search-service', function () {

    this.timeout(10000);

    it('shall fuzzy search this spec file', async () => {
        const service = new FileSearchServiceImpl(new MockLogger());
        const uri = FileUri.create(path.resolve(__dirname, ".."));
        const matches = await service.find(uri.toString(), 'spc');
        const expectedFile = FileUri.create(__filename).toString();
        const testFile = matches.find(e => e.endsWith(expectedFile));
        expect(testFile).to.eql(FileUri.create(__filename).toString());
    });

    it('shall respect nested .gitignore', async () => {
        const service = new FileSearchServiceImpl(new MockLogger());
        const uri = FileUri.create(path.resolve(__dirname, "../../test-resources"));
        const matches = await service.find(uri.toString(), 'foo', { fuzzyMatch: false });

        expect(matches.some(e => e.endsWith('test-resources/foo.txt'))).eq(false);
        expect(matches.some(e => e.endsWith('test-resources/subdir1/sub-bar/foo.txt'))).eq(false);
        expect(matches.some(e => e.endsWith('test-resources/subdir1/sub2/foo.txt'))).eq(true);
{'fraction_non_alphanumeric': 0.15872093023255815, 'fraction_numerical': 0.008430232558139536, 'mean_word_length': 3.733149931224209, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5324334', 'n_tokens_mistral': 1033, 'n_tokens_neox': 997, 'n_words': 247}