Skip to content

Commit 74a5ba5

Browse files
bioflowymr-c
authored andcommitted
fixes #805 The value of copyFrom.fetcher is not used in the LoadingOptions constructor in typescript
1 parent 2378312 commit 74a5ba5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { assert } from 'chai'
2+
import { Fetcher, LoadingOptions } from '../util/Internal'
3+
4+
class TestFetcher implements Fetcher {
5+
checkExists(url: string): boolean {
6+
return true
7+
}
8+
async fetchText(url: string, contentTypes?: string[] | undefined): Promise<string> {
9+
return "TestFetcher"
10+
}
11+
urljoin(baseUrl: string, url: string): string {
12+
return `${baseUrl}/${url}`
13+
}
14+
}
15+
16+
describe('Test LoadingOptions', () => {
17+
describe('copyFrom', () => {
18+
const original = new LoadingOptions({fetcher: new TestFetcher()})
19+
it('should have the same Fetcher as the original', async () => {
20+
const copy = new LoadingOptions({copyFrom:original})
21+
assert.equal(copy.fetcher,original.fetcher)
22+
})
23+
it('fetcher should take precedence over copyFrom', async () => {
24+
const fetcher = new TestFetcher()
25+
const copy = new LoadingOptions({fetcher,copyFrom:original})
26+
assert.equal(copy.fetcher,fetcher)
27+
})
28+
})
29+
})

schema_salad/typescript/util/LoadingOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class LoadingOptions {
2525
if (copyFrom != null) {
2626
this.idx = copyFrom.idx
2727
if (fetcher === undefined) {
28-
this.fetcher = copyFrom.fetcher
28+
fetcher = copyFrom.fetcher
2929
}
3030
if (fileUri === undefined) {
3131
this.fileUri = copyFrom.fileUri

0 commit comments

Comments
 (0)