@@ -15,11 +15,36 @@ import {
1515
1616describe ( "convertCameraType" , ( ) => {
1717 test ( "should convert to supported types" , ( ) => {
18- expect ( convertCameraType ( "spherical" ) ) . toBe ( "spherical" ) ;
19- expect ( convertCameraType ( "equirectangular" ) ) . toBe ( "spherical" ) ;
20- expect ( convertCameraType ( "fisheye" ) ) . toBe ( "fisheye" ) ;
21- expect ( convertCameraType ( "perspective" ) ) . toBe ( "perspective" ) ;
22- expect ( convertCameraType ( "not-supported" ) ) . toBe ( "perspective" ) ;
18+ const equirectangular = convertCameraType ( "equirectangular" , [ ] ) ;
19+ expect ( equirectangular . cameraType ) . toBe ( "spherical" ) ;
20+
21+ const spherical = convertCameraType ( "spherical" , [ ] ) ;
22+ expect ( spherical . cameraType ) . toBe ( "spherical" ) ;
23+
24+ const fisheye = convertCameraType ( "fisheye" , [ 0.5 ] ) ;
25+ expect ( fisheye . cameraType ) . toBe ( "fisheye" ) ;
26+ expect ( fisheye . parameters . length ) . toBe ( 1 ) ;
27+ expect ( fisheye . parameters [ 0 ] ) . toBe ( 0.5 ) ;
28+
29+ const perspective = convertCameraType ( "perspective" , [ 0.2 , 0.3 ] ) ;
30+ expect ( perspective . cameraType ) . toBe ( "perspective" ) ;
31+ expect ( perspective . parameters . length ) . toBe ( 2 ) ;
32+ expect ( perspective . parameters [ 0 ] ) . toBe ( 0.2 ) ;
33+ expect ( perspective . parameters [ 1 ] ) . toBe ( 0.3 ) ;
34+
35+ const incorrect = convertCameraType ( "not-supported" , [ 0.4 ] ) ;
36+ expect ( incorrect . cameraType ) . toBe ( "perspective" ) ;
37+ expect ( incorrect . parameters . length ) . toBe ( 3 ) ;
38+ expect ( incorrect . parameters [ 0 ] ) . toBe ( 0.85 ) ;
39+ expect ( incorrect . parameters [ 1 ] ) . toBe ( 0 ) ;
40+ expect ( incorrect . parameters [ 2 ] ) . toBe ( 0 ) ;
41+
42+ const empty = convertCameraType ( "" , [ 0.4 ] ) ;
43+ expect ( empty . cameraType ) . toBe ( "perspective" ) ;
44+ expect ( empty . parameters . length ) . toBe ( 3 ) ;
45+ expect ( empty . parameters [ 0 ] ) . toBe ( 0.85 ) ;
46+ expect ( empty . parameters [ 1 ] ) . toBe ( 0 ) ;
47+ expect ( empty . parameters [ 2 ] ) . toBe ( 0 ) ;
2348 } ) ;
2449} ) ;
2550
0 commit comments