Tidy up test
This commit is contained in:
@@ -4,58 +4,62 @@ import * as fs from 'fs-extra';
|
|||||||
import { generateMarkdown } from '../../../../src/remote-queries/remote-queries-markdown-generation';
|
import { generateMarkdown } from '../../../../src/remote-queries/remote-queries-markdown-generation';
|
||||||
|
|
||||||
describe('markdown generation', async function() {
|
describe('markdown generation', async function() {
|
||||||
it('for path-problem-query: should generate markdown file for each repo with results', async function() {
|
describe('for path-problem query', async function() {
|
||||||
const pathProblemQuery = JSON.parse(
|
it('should generate markdown file for each repo with results', async function() {
|
||||||
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/path-problem-query.json'), 'utf8')
|
const pathProblemQuery = JSON.parse(
|
||||||
);
|
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/path-problem-query.json'), 'utf8')
|
||||||
|
);
|
||||||
|
|
||||||
const analysesResults = JSON.parse(
|
const analysesResults = JSON.parse(
|
||||||
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/analyses-results.json'), 'utf8')
|
await fs.readFile(path.join(__dirname, 'data/interpreted-results/path-problem/analyses-results.json'), 'utf8')
|
||||||
);
|
);
|
||||||
const markdownFiles = generateMarkdown(pathProblemQuery, analysesResults);
|
const markdownFiles = generateMarkdown(pathProblemQuery, analysesResults);
|
||||||
|
|
||||||
// Check that query has results for two repositories, plus a summary file
|
// Check that query has results for two repositories, plus a summary file
|
||||||
expect(markdownFiles.length).to.equal(3);
|
expect(markdownFiles.length).to.equal(3);
|
||||||
|
|
||||||
const markdownFile0 = markdownFiles[0]; // summary file
|
const markdownFile0 = markdownFiles[0]; // summary file
|
||||||
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
|
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
|
||||||
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
|
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
|
||||||
|
|
||||||
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/path-problem/summary.md');
|
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/path-problem/summary.md');
|
||||||
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo1.md');
|
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo1.md');
|
||||||
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo2.md');
|
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo2.md');
|
||||||
|
|
||||||
// Check that markdown output is correct, after making line endings consistent
|
// Check that markdown output is correct, after making line endings consistent
|
||||||
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
|
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
|
||||||
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
|
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
|
||||||
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
|
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('for problem-query: should generate markdown file for each repo with results', async function() {
|
describe('for problem query', async function() {
|
||||||
const problemQuery = JSON.parse(
|
it('should generate markdown file for each repo with results', async function() {
|
||||||
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/problem-query.json'), 'utf8')
|
const problemQuery = JSON.parse(
|
||||||
);
|
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/problem-query.json'), 'utf8')
|
||||||
|
);
|
||||||
|
|
||||||
const analysesResults = JSON.parse(
|
const analysesResults = JSON.parse(
|
||||||
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/analyses-results.json'), 'utf8')
|
await fs.readFile(path.join(__dirname, 'data/interpreted-results/problem/analyses-results.json'), 'utf8')
|
||||||
);
|
);
|
||||||
const markdownFiles = generateMarkdown(problemQuery, analysesResults);
|
const markdownFiles = generateMarkdown(problemQuery, analysesResults);
|
||||||
|
|
||||||
// Check that query has results for two repositories, plus a summary file
|
// Check that query has results for two repositories, plus a summary file
|
||||||
expect(markdownFiles.length).to.equal(3);
|
expect(markdownFiles.length).to.equal(3);
|
||||||
|
|
||||||
const markdownFile0 = markdownFiles[0]; // summary file
|
const markdownFile0 = markdownFiles[0]; // summary file
|
||||||
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
|
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
|
||||||
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
|
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
|
||||||
|
|
||||||
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/problem/summary.md');
|
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/problem/summary.md');
|
||||||
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/problem/results-repo1.md');
|
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/problem/results-repo1.md');
|
||||||
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/problem/results-repo2.md');
|
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/problem/results-repo2.md');
|
||||||
|
|
||||||
// Check that markdown output is correct, after making line endings consistent
|
// Check that markdown output is correct, after making line endings consistent
|
||||||
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
|
expect(markdownFile0.join('\n')).to.equal(expectedSummaryFile);
|
||||||
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
|
expect(markdownFile1.join('\n')).to.equal(expectedTestOutput1);
|
||||||
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
|
expect(markdownFile2.join('\n')).to.equal(expectedTestOutput2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user