File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Point } from '../../geometry' ;
1
2
import { variance } from '../variance' ;
2
3
3
4
test ( '1x1 RGB image' , ( ) => {
@@ -34,3 +35,25 @@ test('variance from points', () => {
34
35
35
36
expect ( result ) . toStrictEqual ( [ 125 ] ) ;
36
37
} ) ;
38
+ test ( 'must throw if array is empty' , ( ) => {
39
+ const image = testUtils . createRgbaImage ( [
40
+ [ 1 , 2 , 2 , 2 ] ,
41
+ [ 1 , 2 , 3 , 2 ] ,
42
+ ] ) ;
43
+ const points : Point [ ] = [ ] ;
44
+ expect ( ( ) => {
45
+ const result = image . median ( { points } ) ;
46
+ return result ;
47
+ } ) . toThrow ( 'Array of coordinates is empty.' ) ;
48
+ } ) ;
49
+ test ( "must throw if point's coordinates are invalid" , ( ) => {
50
+ const image = testUtils . createGreyImage ( [
51
+ [ 1 , 2 , 2 , 2 ] ,
52
+ [ 1 , 2 , 3 , 2 ] ,
53
+ ] ) ;
54
+ const points : Point [ ] = [ { column : 0 , row : 2 } ] ;
55
+ expect ( ( ) => {
56
+ const result = image . median ( { points } ) ;
57
+ return result ;
58
+ } ) . toThrow ( 'Invalid coordinate: {column: 0, row: 2}' ) ;
59
+ } ) ;
You can’t perform that action at this time.
0 commit comments