Files
vscode-codeql/extensions/ql-vscode/test/pure-tests/location.test.ts
Andrew Eisenberg 1efa9f1082 Update contributing documentation and launch config
Adds section in CONTRIBUTING.md to document how to run tests. Also,
fixes some markdown linting warnings.

And fixes the launch config for running unit tests.
2020-03-07 16:36:09 -08:00

32 lines
1.1 KiB
TypeScript

import { expect } from 'chai';
import 'mocha';
import { LocationStyle, StringLocation, tryGetWholeFileLocation } from 'semmle-bqrs';
describe('processing string locations', function () {
it('should detect Windows whole-file locations', function () {
const loc: StringLocation = {
t: LocationStyle.String,
loc: 'file://C:/path/to/file.ext:0:0:0:0'
};
const wholeFileLoc = tryGetWholeFileLocation(loc);
expect(wholeFileLoc).to.eql({t: LocationStyle.WholeFile, file: 'C:/path/to/file.ext'});
});
it('should detect Unix whole-file locations', function () {
const loc: StringLocation = {
t: LocationStyle.String,
loc: 'file:///path/to/file.ext:0:0:0:0'
};
const wholeFileLoc = tryGetWholeFileLocation(loc);
expect(wholeFileLoc).to.eql({t: LocationStyle.WholeFile, file: '/path/to/file.ext'});
});
it('should ignore other string locations', function () {
for (const loc of ['file:///path/to/file.ext', 'I am not a location']) {
const wholeFileLoc = tryGetWholeFileLocation({
t: LocationStyle.String,
loc: loc
});
expect(wholeFileLoc).to.be.undefined;
}
});
});