-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathgenerate.test.js
38 lines (33 loc) · 1.43 KB
/
generate.test.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
import { existsSync, readFileSync } from 'fs';
import { execSync } from 'child_process';
describe('Build test: generate.js', () => {
beforeAll(() => {
});
describe('generate.js', () => {
describe('command line arguments', () => {
beforeEach(() => {
execSync('rm -rf testBuildOutput');
});
afterEach(() => {
execSync('rm -rf testBuildOutput');
});
it('should correctly handle option -d', async() => {
execSync('node bin/generate.js -d testBuildOutput', { encoding: 'utf-8' }); // the default is 'buffer'
expect(existsSync('testBuildOutput')).toEqual(true);
});
it('should correctly handle option -q', async() => {
execSync('node bin/generate.js -d testBuildOutput -q tests/test-queries', { encoding: 'utf-8' }); // the default is 'buffer'
let buildQueries = JSON.parse(readFileSync("./build/queries.json")).queries;
expect(buildQueries).toEqual(
[
{
"name":"1",
"datasources":[],
"queryFormat":"sparql",
"query":"prefix ex: <http://example.org/>\nSELECT ?a ?b WHERE {\n ?a ex:example ?b.\n}"
}
]);
});
});
});
});