@@ -4,49 +4,27 @@ const aspectRatio = require('..')
4
4
const should = require ( 'should' )
5
5
6
6
describe ( 'aspect ratio' , ( ) => {
7
- it ( '1024x768' , ( ) => {
8
- should ( aspectRatio ( 1024 , 768 ) ) . equal ( '4:3' )
9
- } )
10
-
11
- it ( '1920x1080' , ( ) => {
12
- should ( aspectRatio ( 1920 , 1080 ) ) . equal ( '16:9' )
13
- } )
14
-
15
- it ( '1280x1024' , ( ) => {
16
- should ( aspectRatio ( 1280 , 1024 ) ) . equal ( '5:4' )
17
- } )
18
-
19
- it ( 'using other separator' , ( ) => {
20
- should ( aspectRatio ( 1920 , 1080 , '/' ) ) . equal ( '16/9' )
21
- } )
22
-
23
- it ( 'invalid width' , ( ) => {
24
- let error = ''
25
- try {
26
- should ( aspectRatio ( 1920 , null , '/' ) ) . equal ( '16/9' )
27
- } catch ( e ) {
28
- error = e . message
29
- }
30
- should ( error ) . equal ( 'Invalid width: null' )
31
- } )
32
-
33
- it ( 'invalid height' , ( ) => {
34
- let error = ''
35
- try {
36
- should ( aspectRatio ( null , 1080 , '/' ) ) . equal ( '16/9' )
37
- } catch ( e ) {
38
- error = e . message
39
- }
40
- should ( error ) . equal ( 'Invalid height: null' )
41
- } )
42
-
43
- it ( 'invalid width & height' , ( ) => {
44
- let error = ''
45
- try {
46
- should ( aspectRatio ( null , null ) ) . equal ( '16/9' )
47
- } catch ( e ) {
48
- error = e . message
49
- }
50
- should ( error ) . equal ( 'Invalid height: null' )
7
+ it ( '1024x768' , ( ) => should ( aspectRatio ( 1024 , 768 ) ) . equal ( '4:3' ) )
8
+ it ( '1920x1080' , ( ) => should ( aspectRatio ( 1920 , 1080 ) ) . equal ( '16:9' ) )
9
+ it ( '1280x1024' , ( ) => should ( aspectRatio ( 1280 , 1024 ) ) . equal ( '5:4' ) )
10
+ it ( 'specifying output separator' , ( ) =>
11
+ should ( aspectRatio ( 1920 , 1080 , '/' ) ) . equal ( '16/9' ) )
12
+
13
+ describe ( 'invalid input' , ( ) => {
14
+ ; [
15
+ [ 1920 , null , '/' ] ,
16
+ [ null , 1080 , '/' ] ,
17
+ [ null , null ] ,
18
+ [ undefined , undefined ] ,
19
+ [ '1920' , '1080' ]
20
+ ] . forEach ( input => {
21
+ it ( JSON . stringify ( input ) , ( ) => {
22
+ try {
23
+ aspectRatio ( ...input )
24
+ } catch ( { message } ) {
25
+ should ( message . includes ( 'Invalid' ) ) . be . true ( )
26
+ }
27
+ } )
28
+ } )
51
29
} )
52
30
} )
0 commit comments