Skip to content

Commit

Permalink
feat: support extension API v25.2.0 (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjkandala committed May 6, 2021
1 parent 97b0ed9 commit dd36b7f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -67,6 +67,6 @@
"@types/sinon": "9.0.4",
"rxjs": "^6.5.1",
"sinon": "^9.0.2",
"sourcegraph": "^25.0.0"
"sourcegraph": "^25.2.0"
}
}
6 changes: 6 additions & 0 deletions src/api.test.ts
Expand Up @@ -15,6 +15,12 @@ describe('createStubSourcegraphAPI()', () => {
assert.deepStrictEqual(stub.app.createDecorationType(), { key: 'decorationType1' })
assert.deepStrictEqual(stub.app.createDecorationType(), { key: 'decorationType2' })
})
it('should support creating unique statusBarItemTypes', () => {
const stub = createStubSourcegraphAPI()
assert.deepStrictEqual(stub.app.createStatusBarItemType(), { key: 'statusBarItemType0' })
assert.deepStrictEqual(stub.app.createStatusBarItemType(), { key: 'statusBarItemType1' })
assert.deepStrictEqual(stub.app.createStatusBarItemType(), { key: 'statusBarItemType2' })
})
it('should support managing the active Window', () => {
const stub = createStubSourcegraphAPI()
const newWindow = {} as sourcegraph.Window
Expand Down
6 changes: 6 additions & 0 deletions src/api.ts
Expand Up @@ -14,6 +14,7 @@ import * as sourcegraph from 'sourcegraph'
import { notImplemented, subtypeOf } from './util'

let decorationTypeCounter = 0
let statusBarItemTypeCounter = 0

/**
* Creates an object that (mostly) implements the Sourcegraph API,
Expand Down Expand Up @@ -54,6 +55,10 @@ export const createStubSourcegraphAPI = () => {
get versionContext() {
return this.versionContextChanges.value
},
searchContextChanges: new BehaviorSubject(undefined),
get searchContext() {
return this.searchContextChanges.value
},
},
languages: {
registerHoverProvider: sinon.spy(
Expand Down Expand Up @@ -92,6 +97,7 @@ export const createStubSourcegraphAPI = () => {
registerFileDecorationProvider: sinon.spy(
(provider: sourcegraph.FileDecorationProvider) => new Subscription()
),
createStatusBarItemType: () => ({ key: `statusBarItemType${statusBarItemTypeCounter++}` }),
},
configuration: Object.assign(configSubject.pipe(mapTo(undefined)), {
get: <C extends object = { [key: string]: any }>(): sourcegraph.Configuration<C> => ({
Expand Down
3 changes: 3 additions & 0 deletions src/codeEditor.test.ts
Expand Up @@ -20,5 +20,8 @@ describe('createStubCodeEditor()', () => {

stub.setDecorations({ key: 'foo' }, [{ range: new Range(0, 1, 2, 3), border: 'red' }])
sinon.assert.calledOnce(stub.setDecorations)

stub.setStatusBarItem({ key: 'foo' }, { text: 'status bar item' })
sinon.assert.calledOnce(stub.setStatusBarItem)
})
})
4 changes: 4 additions & 0 deletions src/codeEditor.ts
Expand Up @@ -23,6 +23,10 @@ export const createStubCodeEditor = ({
decorations: sourcegraph.TextDocumentDecoration[]
): void => undefined
),
setStatusBarItem: sinon.spy(
(statusBarItemType: sourcegraph.StatusBarItemType, statusBarItem: sourcegraph.StatusBarItem): void =>
undefined
),
})
return codeEditor
}
2 changes: 1 addition & 1 deletion src/util.test.ts
@@ -1,7 +1,7 @@
import assert from 'assert'
import { notImplemented } from './util'

describe('notImplemted', () => {
describe('notImplemented', () => {
it('throws', () => {
assert.throws(notImplemented, /not implemented/i)
})
Expand Down
16 changes: 4 additions & 12 deletions yarn.lock
Expand Up @@ -4839,7 +4839,6 @@ npm@^6.14.8:
cmd-shim "^3.0.3"
columnify "~1.5.4"
config-chain "^1.1.12"
debuglog "*"
detect-indent "~5.0.0"
detect-newline "^2.1.0"
dezalgo "~1.0.3"
Expand All @@ -4854,7 +4853,6 @@ npm@^6.14.8:
has-unicode "~2.0.1"
hosted-git-info "^2.8.8"
iferr "^1.0.2"
imurmurhash "*"
infer-owner "^1.0.4"
inflight "~1.0.6"
inherits "^2.0.4"
Expand All @@ -4873,14 +4871,8 @@ npm@^6.14.8:
libnpx "^10.2.4"
lock-verify "^2.1.0"
lockfile "^1.0.4"
lodash._baseindexof "*"
lodash._baseuniq "~4.6.0"
lodash._bindcallback "*"
lodash._cacheindexof "*"
lodash._createcache "*"
lodash._getnative "*"
lodash.clonedeep "~4.5.0"
lodash.restparam "*"
lodash.union "~4.6.0"
lodash.uniq "~4.5.0"
lodash.without "~4.4.0"
Expand Down Expand Up @@ -6285,10 +6277,10 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

sourcegraph@^25.0.0:
version "25.0.0"
resolved "https://registry.yarnpkg.com/sourcegraph/-/sourcegraph-25.0.0.tgz#5f16eb684ee23b59011e68d516df7755ebaa47f8"
integrity sha512-3deJcXdOdKoI5xZv4wiQXOnJw96I/BFLStwHHbUS1XlDP1yHHKQT3pKsTawm/YJ8CUirBYkIVsAA2rR/JYO4Ew==
sourcegraph@^25.2.0:
version "25.2.0"
resolved "https://registry.yarnpkg.com/sourcegraph/-/sourcegraph-25.2.0.tgz#7978b3ca154e2703828cd4bd2fdfbc3f7994bbe8"
integrity sha512-2yYJN8DMFrGesDfZvaYfXie86fHl3HtPRZ4XImQ6H4d7HuHHYEkVYxlbrOD4BUgMBsit5oVUPZ9Kspu0676QAA==

spawn-error-forwarder@~1.0.0:
version "1.0.0"
Expand Down

0 comments on commit dd36b7f

Please sign in to comment.