This refactoring combines the types in `bqrs-types.ts` and `bqrs-cli-types.ts`. Historically, the former was used for BQRS files parsed by the extension and the latter for BQRS files parsed by the cli. They describe the same file types, but using different property and type names. We have moved to parsing all BQRS files by the cli. This refactoring removes the `bqrs-types.ts` file and replaces all BQRS references to use types in `bqrs-cli-types.ts`. Additionally, the `adapt.ts` file has been deleted since its purpose was to convert between extension and cli BQRS types. Some one type and one function from `adapt.ts` has been moved from `adapt.ts` to `bqrs-types.ts`. It's possible that we want to do a further refactoring to simply remove them both.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { expect } from 'chai';
|
|
import 'mocha';
|
|
import { tryGetResolvableLocation } from '../../src/bqrs-utils';
|
|
|
|
describe('processing string locations', function() {
|
|
it('should detect Windows whole-file locations', function() {
|
|
const loc = 'file://C:/path/to/file.ext:0:0:0:0';
|
|
const wholeFileLoc = tryGetResolvableLocation(loc);
|
|
expect(wholeFileLoc).to.eql({ uri: 'C:/path/to/file.ext' });
|
|
});
|
|
it('should detect Unix whole-file locations', function() {
|
|
const loc = 'file:///path/to/file.ext:0:0:0:0';
|
|
const wholeFileLoc = tryGetResolvableLocation(loc);
|
|
expect(wholeFileLoc).to.eql({ uri: '/path/to/file.ext' });
|
|
});
|
|
|
|
it('should detect Unix 5-part locations', function() {
|
|
const loc = 'file:///path/to/file.ext:1:2:3:4';
|
|
const wholeFileLoc = tryGetResolvableLocation(loc);
|
|
expect(wholeFileLoc).to.eql({
|
|
uri: '/path/to/file.ext',
|
|
startLine: 1,
|
|
startColumn: 2,
|
|
endLine: 3,
|
|
endColumn: 4
|
|
});
|
|
});
|
|
it('should ignore other string locations', function() {
|
|
for (const loc of ['file:///path/to/file.ext', 'I am not a location']) {
|
|
const wholeFileLoc = tryGetResolvableLocation(loc);
|
|
expect(wholeFileLoc).to.be.undefined;
|
|
}
|
|
});
|
|
});
|