Skip to content

Commit

Permalink
Do not log not found errors when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed May 6, 2020
1 parent c2badcf commit c5fbc64
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ describe('Validate getDictionary', () => {
{
name: 'temp',
path: tempDictPath
},
{
name: 'not_found',
path: tempDictPath
}
]);
const toLoad = ['node', 'html', 'css', 'temp'];
const toLoad = ['node', 'html', 'css', 'not_found', 'temp', ];
const dicts = await Promise.all(Dictionaries.loadDictionaries(toLoad, defs));

expect(dicts[3].has('one')).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { testing, LoadOptions, loadDictionary } from './DictionaryLoader';
import * as path from 'path';
jest.mock('../util/logger');


const root = path.join(__dirname, '..', '..');
const dictionaries = path.join(root, 'dictionaries');
Expand Down
4 changes: 4 additions & 0 deletions packages/cspell-lib/src/util/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export function logError(e: any) {
console.log(e);
}
2 changes: 2 additions & 0 deletions packages/cspell-lib/src/wordListHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as wlh from './wordListHelper';

jest.mock('./util/logger');

describe('Validate wordListHelper', () => {
test('tests splitLineIntoWords', () => {
const line = 'New York City';
Expand Down
5 changes: 1 addition & 4 deletions packages/cspell-lib/src/wordListHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Text from './util/text';
import { readLines } from './util/fileReader';
import { xregexp as XRegExp } from 'cspell-util-bundle';
import { toIterableIterator, concatIterables } from './util/iterableIteratorLib';
import { logError } from './util/logger';


const regExpWordsWithSpaces = XRegExp('^\\s*\\p{L}+(?:\\s+\\p{L}+){0,3}$');
Expand All @@ -23,10 +24,6 @@ export function loadWordsNoError(filename: string) {
);
}

function logError(e: any) {
console.log(e);
}

export function splitLine(line: string) {
return Text.extractWordsFromText(line).map(({text}) => text).toArray();
}
Expand Down

0 comments on commit c5fbc64

Please sign in to comment.