Skip to content

Commit

Permalink
fixes #805 The value of copyFrom.fetcher is not used in the LoadingOp…
Browse files Browse the repository at this point in the history
…tions constructor in typescript
  • Loading branch information
bioflowy authored and mr-c committed Apr 10, 2024
1 parent 2378312 commit 74a5ba5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions schema_salad/typescript/test/LoadingOptions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { assert } from 'chai'
import { Fetcher, LoadingOptions } from '../util/Internal'

class TestFetcher implements Fetcher {
checkExists(url: string): boolean {
return true
}
async fetchText(url: string, contentTypes?: string[] | undefined): Promise<string> {
return "TestFetcher"
}
urljoin(baseUrl: string, url: string): string {
return `${baseUrl}/${url}`
}
}

describe('Test LoadingOptions', () => {
describe('copyFrom', () => {
const original = new LoadingOptions({fetcher: new TestFetcher()})
it('should have the same Fetcher as the original', async () => {
const copy = new LoadingOptions({copyFrom:original})
assert.equal(copy.fetcher,original.fetcher)
})
it('fetcher should take precedence over copyFrom', async () => {
const fetcher = new TestFetcher()
const copy = new LoadingOptions({fetcher,copyFrom:original})
assert.equal(copy.fetcher,fetcher)
})
})
})
2 changes: 1 addition & 1 deletion schema_salad/typescript/util/LoadingOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class LoadingOptions {
if (copyFrom != null) {
this.idx = copyFrom.idx
if (fetcher === undefined) {
this.fetcher = copyFrom.fetcher
fetcher = copyFrom.fetcher
}
if (fileUri === undefined) {
this.fileUri = copyFrom.fileUri
Expand Down

0 comments on commit 74a5ba5

Please sign in to comment.