Skip to content

Commit 908a862

Browse files
committed
Tidy up test
1 parent 6676ba9 commit 908a862

1 file changed

Lines changed: 44 additions & 40 deletions

File tree

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/markdown-generation.test.ts

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,62 @@ import * as fs from 'fs-extra';
44
import { generateMarkdown } from '../../../../src/remote-queries/remote-queries-markdown-generation';
55

66
describe('markdown generation', async function() {
7-
it('for path-problem-query: should generate markdown file for each repo with results', async function() {
8-
const pathProblemQuery = JSON.parse(
9-
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/path-problem-query.json'), 'utf8')
10-
);
7+
describe('for path-problem query', async function() {
8+
it('should generate markdown file for each repo with results', async function() {
9+
const pathProblemQuery = JSON.parse(
10+
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/path-problem-query.json'), 'utf8')
11+
);
1112

12-
const analysesResults = JSON.parse(
13-
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/analyses-results.json'), 'utf8')
14-
);
15-
const markdownFiles = generateMarkdown(pathProblemQuery, analysesResults);
13+
const analysesResults = JSON.parse(
14+
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/analyses-results.json'), 'utf8')
15+
);
16+
const markdownFiles = generateMarkdown(pathProblemQuery, analysesResults);
1617

17-
// Check that query has results for two repositories, plus a summary file
18-
expect(markdownFiles.length).to.equal(3);
18+
// Check that query has results for two repositories, plus a summary file
19+
expect(markdownFiles.length).to.equal(3);
1920

20-
const markdownFile0 = markdownFiles[0]; // summary file
21-
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
22-
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
21+
const markdownFile0 = markdownFiles[0]; // summary file
22+
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
23+
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
2324

24-
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/path-problem/summary.md');
25-
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo1.md');
26-
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo2.md');
25+
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/path-problem/summary.md');
26+
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo1.md');
27+
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo2.md');
2728

28-
// Check that markdown output is correct, after making line endings consistent
29-
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
30-
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
31-
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
29+
// Check that markdown output is correct, after making line endings consistent
30+
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
31+
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
32+
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
33+
});
3234
});
3335

34-
it('for problem-query: should generate markdown file for each repo with results', async function() {
35-
const problemQuery = JSON.parse(
36-
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/problem-query.json'), 'utf8')
37-
);
36+
describe('for problem query', async function() {
37+
it('should generate markdown file for each repo with results', async function() {
38+
const problemQuery = JSON.parse(
39+
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/problem-query.json'), 'utf8')
40+
);
3841

39-
const analysesResults = JSON.parse(
40-
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/analyses-results.json'), 'utf8')
41-
);
42-
const markdownFiles = generateMarkdown(problemQuery, analysesResults);
42+
const analysesResults = JSON.parse(
43+
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/analyses-results.json'), 'utf8')
44+
);
45+
const markdownFiles = generateMarkdown(problemQuery, analysesResults);
4346

44-
// Check that query has results for two repositories, plus a summary file
45-
expect(markdownFiles.length).to.equal(3);
47+
// Check that query has results for two repositories, plus a summary file
48+
expect(markdownFiles.length).to.equal(3);
4649

47-
const markdownFile0 = markdownFiles[0]; // summary file
48-
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
49-
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
50+
const markdownFile0 = markdownFiles[0]; // summary file
51+
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
52+
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
5053

51-
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/problem/summary.md');
52-
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/problem/results-repo1.md');
53-
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/problem/results-repo2.md');
54+
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/problem/summary.md');
55+
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/problem/results-repo1.md');
56+
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/problem/results-repo2.md');
5457

55-
// Check that markdown output is correct, after making line endings consistent
56-
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
57-
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
58-
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
58+
// Check that markdown output is correct, after making line endings consistent
59+
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
60+
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
61+
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
62+
});
5963
});
6064
});
6165

0 commit comments

Comments
 (0)