Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract driver(s) for service tests #221

Open
amir-arad opened this issue May 23, 2018 · 2 comments
Open

extract driver(s) for service tests #221

amir-arad opened this issue May 23, 2018 · 2 comments

Comments

@amir-arad
Copy link
Contributor

amir-arad commented May 23, 2018

currently the tests in test/lib/service.spec.ts have a lot of verbose code (boilerplate, shallow namespace, magic numbers etc. ) that can be made much more readable with relatively little effort.

the concept not necessarily the perfect API):

const {fs, fsDriver} = makeTestFs();
const fooDriver : {name, text, Document, positions} = fsDriver
.addFile('foo.bar' /* fileName*/, editorText`
    |foo${1}bar
    |${2}biz${1}${2}baz
` /* string | contentAndPositions */ , 'pseudocode' /* languageId */);
fooDriver.positions.range(1)  // returns the range between the two 1's from the template
fooDriver.positions.last(2) // returns the position of the last 2 from the template

where editorText removes pipe indentation, and computes positions (returns contentAndPositions).
Document is a result of TextDocumentItem.create(...)
name and text are the name and content of the file for easy reference down the test.

the test drivers themselves of course have to be tested. see test/testkit/text.spec.ts for example.

@amir-arad
Copy link
Contributor Author

pipe indent trimming is already implemented by trimLiteral.

@amir-arad
Copy link
Contributor Author

amir-arad commented May 23, 2018

another feature can be .getAllPositions(1 /* position key*/) which returns an array of LSP positions in that file, ready for command API (i.e definition request) [{ position: { line: x, character: y }, textDocument:{...} }, ...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants