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

fixed #29 The value of copyFrom.fetcher is not used in the LoadingOpt… #30

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/test/LoadingOptions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { assert } from 'chai'
import { _IdMapLoader, Fetcher, LoadingOptions, ValidationException } from '../util/Internal'

class TestFetcher implements Fetcher {
checkExists(url: string): boolean {
return true

Check warning on line 6 in src/test/LoadingOptions.spec.ts

View check run for this annotation

Codecov / codecov/patch

src/test/LoadingOptions.spec.ts#L6

Added line #L6 was not covered by tests
}
async fetchText(url: string, contentTypes?: string[] | undefined): Promise<string> {
return "TestFetcher"

Check warning on line 9 in src/test/LoadingOptions.spec.ts

View check run for this annotation

Codecov / codecov/patch

src/test/LoadingOptions.spec.ts#L9

Added line #L9 was not covered by tests
}
urljoin(baseUrl: string, url: string): string {
return `${baseUrl}/${url}`

Check warning on line 12 in src/test/LoadingOptions.spec.ts

View check run for this annotation

Codecov / codecov/patch

src/test/LoadingOptions.spec.ts#L12

Added line #L12 was not covered by tests
}
}

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 src/util/LoadingOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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
Loading