File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 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+ } )
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments