1
1
import { Region } from "./region.class" ;
2
2
3
3
describe ( "Region" , ( ) => {
4
- it ( "should calcutate the correct area of a region" , ( ) => {
4
+ it ( "should calculate the correct area of a region" , ( ) => {
5
5
const region = new Region ( 0 , 0 , 100 , 100 ) ;
6
6
const expected = 10000 ;
7
7
@@ -14,56 +14,4 @@ describe("Region", () => {
14
14
15
15
expect ( region . toString ( ) ) . toEqual ( expected ) ;
16
16
} ) ;
17
-
18
- it ( "should scale and translate in x" , ( ) => {
19
- const scaleFactor = 2.0 ;
20
- const region = new Region ( 100 , 100 , 100 , 100 ) ;
21
- const result = Region . scaled ( region , scaleFactor ) ;
22
-
23
- expect ( result . left ) . toBeCloseTo ( region . left * scaleFactor ) ;
24
- expect ( result . width ) . toBeCloseTo ( region . width * scaleFactor ) ;
25
- expect ( result . top ) . toBeCloseTo ( region . top ) ;
26
- expect ( result . height ) . toBeCloseTo ( region . height ) ;
27
- } ) ;
28
-
29
- it ( "should scale and translate in y" , ( ) => {
30
- const scaleFactor = 2.0 ;
31
- const region = new Region ( 200 , 250 , 100 , 100 ) ;
32
- const result = Region . scaled ( region , undefined , scaleFactor ) ;
33
-
34
- expect ( result . left ) . toBeCloseTo ( region . left ) ;
35
- expect ( result . width ) . toBeCloseTo ( region . width ) ;
36
- expect ( result . top ) . toBeCloseTo ( region . top * scaleFactor ) ;
37
- expect ( result . height ) . toBeCloseTo ( region . height * scaleFactor ) ;
38
- } ) ;
39
-
40
- it ( "should scale and translate in both x and y" , ( ) => {
41
- const scaleFactorX = 1.75 ;
42
- const scaleFactorY = 2.5 ;
43
- const region = new Region ( 300 , 720 , 100 , 100 ) ;
44
- const result = Region . scaled ( region , scaleFactorX , scaleFactorY ) ;
45
-
46
- expect ( result . left ) . toBeCloseTo ( region . left * scaleFactorX ) ;
47
- expect ( result . width ) . toBeCloseTo ( region . width * scaleFactorX ) ;
48
- expect ( result . top ) . toBeCloseTo ( region . top * scaleFactorY ) ;
49
- expect ( result . height ) . toBeCloseTo ( region . height * scaleFactorY ) ;
50
- } ) ;
51
-
52
- it ( "should throw an error when scaling to 0 in x" , ( ) => {
53
- const scaleFactorX = 0.0 ;
54
- const scaleFactorY = 2.5 ;
55
- const region = new Region ( 300 , 720 , 100 , 100 ) ;
56
- expect ( ( ) => Region . scaled ( region , scaleFactorX , scaleFactorY ) ) . toThrow (
57
- `Scaling to 0. Please check parameters: scaleX: ${ scaleFactorX } , scaleY: ${ scaleFactorY } ` ,
58
- ) ;
59
- } ) ;
60
-
61
- it ( "should throw an error when scaling to 0 in y" , ( ) => {
62
- const scaleFactorX = 2.5 ;
63
- const scaleFactorY = 0.0 ;
64
- const region = new Region ( 300 , 720 , 100 , 100 ) ;
65
- expect ( ( ) => Region . scaled ( region , scaleFactorX , scaleFactorY ) ) . toThrow (
66
- `Scaling to 0. Please check parameters: scaleX: ${ scaleFactorX } , scaleY: ${ scaleFactorY } ` ,
67
- ) ;
68
- } ) ;
69
17
} ) ;
0 commit comments