/
golang.spec.ts
25 lines (23 loc) · 1.29 KB
/
golang.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as cspell from '../index';
import * as path from 'path';
import * as fsp from 'fs-extra';
const sampleFilename = path.join(__dirname, '..', '..', 'samples', 'src', 'sample.go');
const sampleFile = fsp.readFile(sampleFilename, 'utf8').then((buffer) => buffer.toString());
describe('Validate that Go files are correctly checked.', () => {
jest.setTimeout(10000);
test('Tests the default configuration', async () => {
const text = await sampleFile;
expect(Object.keys(text)).not.toHaveLength(0);
const ext = '.go';
const languageIds = cspell.getLanguagesForExt(ext);
const settings = cspell.getDefaultBundledSettings();
const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds);
// cspell:ignore weirdd garbbage longname
const results1 = await cspell.validateText('some weirdd garbbage', fileSettings);
expect(results1.map((t) => t.text)).toEqual(expect.arrayContaining(['weirdd']));
expect(results1.map((t) => t.text)).toEqual(expect.arrayContaining(['garbbage']));
const results = await cspell.validateText(text, fileSettings);
expect(results).toHaveLength(3);
expect(results.map((t) => t.text)).toEqual(expect.arrayContaining(['longname', 'garbbage']));
});
});