@@ -10,32 +10,50 @@ import Terria from "../../../../lib/Models/Terria";
10
10
import TerriaFeature from "../../../../lib/Models/Feature/Feature" ;
11
11
12
12
describe ( "WebMapServiceCatalogItem" , function ( ) {
13
- it ( "derives getCapabilitiesUrl from url if getCapabilitiesUrl is not specified" , function ( ) {
14
- const terria = new Terria ( ) ;
15
- const wms = new WebMapServiceCatalogItem ( "test" , terria ) ;
16
- wms . setTrait ( "definition" , "url" , "foo.bar.baz" ) ;
17
- expect ( wms . getCapabilitiesUrl ) . toBeDefined ( ) ;
18
- expect ( wms . url ) . toBeDefined ( ) ;
19
- expect (
20
- wms . getCapabilitiesUrl &&
21
- wms . getCapabilitiesUrl . indexOf ( wms . url || "undefined" ) === 0
22
- ) . toBe ( true ) ;
13
+ describe ( "derives getCapabilitiesUrl from url" , ( ) => {
14
+ it ( "if getCapabilitiesUrl is not specified" , function ( ) {
15
+ const terria = new Terria ( ) ;
16
+ const wms = new WebMapServiceCatalogItem ( "test" , terria ) ;
17
+ wms . setTrait ( "definition" , "url" , "foo.bar.baz" ) ;
18
+ expect ( wms . getCapabilitiesUrl ) . toBeDefined ( ) ;
19
+ expect ( wms . url ) . toBeDefined ( ) ;
20
+ expect (
21
+ wms . getCapabilitiesUrl &&
22
+ wms . getCapabilitiesUrl . indexOf ( wms . url || "undefined" ) === 0
23
+ ) . toBe ( true ) ;
23
24
24
- expect ( wms . useWmsVersion130 ) . toBeTruthy ( ) ;
25
- } ) ;
25
+ expect ( wms . useWmsVersion130 ) . toBeTruthy ( ) ;
26
+ } ) ;
26
27
27
- it ( "derives getCapabilitiesUrl from url - for WMS 1.1.1" , function ( ) {
28
- const terria = new Terria ( ) ;
29
- const wms = new WebMapServiceCatalogItem ( "test" , terria ) ;
30
- wms . setTrait (
31
- "definition" ,
32
- "url" ,
33
- "http://www.bom.gov.au/cgi-bin/ws/gis/ncc/cdio/wxs?service=WMS&version=1.1.1&request=GetCapabilities"
34
- ) ;
35
- expect ( wms . getCapabilitiesUrl ) . toBeDefined ( ) ;
36
- expect ( wms . url ) . toBeDefined ( ) ;
28
+ it ( "for WMS 1.1.1" , function ( ) {
29
+ const terria = new Terria ( ) ;
30
+ const wms = new WebMapServiceCatalogItem ( "test" , terria ) ;
31
+ wms . setTrait (
32
+ "definition" ,
33
+ "url" ,
34
+ "http://www.bom.gov.au/cgi-bin/ws/gis/ncc/cdio/wxs?service=WMS&version=1.1.1&request=GetCapabilities"
35
+ ) ;
36
+ expect ( wms . getCapabilitiesUrl ) . toBeDefined ( ) ;
37
+ expect ( wms . url ) . toBeDefined ( ) ;
37
38
38
- expect ( wms . useWmsVersion130 ) . toBeFalsy ( ) ;
39
+ expect ( wms . useWmsVersion130 ) . toBeFalsy ( ) ;
40
+ } ) ;
41
+
42
+ it ( "drops query bad parameters" , function ( ) {
43
+ const terria = new Terria ( ) ;
44
+ const wms = new WebMapServiceCatalogItem ( "test" , terria ) ;
45
+ wms . setTrait (
46
+ "definition" ,
47
+ "url" ,
48
+ "http://www.bom.gov.au/cgi-bin/ws/gis/ncc/cdio/wxs?service=WMS&version=1.1.1&request=GetMap&format=something&allowed=yes"
49
+ ) ;
50
+ expect ( wms . getCapabilitiesUrl ) . toBeDefined ( ) ;
51
+ expect ( wms . url ) . toBeDefined ( ) ;
52
+
53
+ const queryParameters = new URL ( wms . getCapabilitiesUrl ! ) . searchParams ;
54
+ expect ( queryParameters . get ( "format" ) ) . toBeNull ( ) ;
55
+ expect ( queryParameters . get ( "allowed" ) ) . toBe ( "yes" ) ;
56
+ } ) ;
39
57
} ) ;
40
58
41
59
it ( "loads" , function ( ) {
0 commit comments