1
1
var test = require ( "tape" )
2
2
var reduceCssCalc = require ( ".." )
3
3
4
- test ( "throws an syntax error if a parenthese is missing" , function ( t ) {
4
+ test ( "throws an syntax error if a parenthese is missing" , function ( t ) {
5
5
t . throws ( function ( ) { reduceCssCalc ( "calc(" ) } , SyntaxError )
6
6
t . throws ( function ( ) { reduceCssCalc ( "calc((2 + 1)" ) } , SyntaxError )
7
7
t . throws ( function ( ) { reduceCssCalc ( "a calc(calc(2 + 1) b()" ) } , SyntaxError )
8
8
t . end ( )
9
9
} )
10
10
11
- test ( "throws an error if a calc() is empty" , function ( t ) {
11
+ test ( "throws an error if a calc() is empty" , function ( t ) {
12
12
t . throws ( function ( ) { reduceCssCalc ( "calc()" ) } , Error )
13
13
t . throws ( function ( ) { reduceCssCalc ( "calc(2 + ())" ) } , SyntaxError )
14
14
t . throws ( function ( ) { reduceCssCalc ( "calc(2 + calc())" ) } , SyntaxError )
15
15
t . end ( )
16
16
} )
17
17
18
- test ( "complete reduce for simple css calc()" , function ( t ) {
18
+ test ( "complete reduce for simple css calc()" , function ( t ) {
19
19
t . equal ( reduceCssCalc ( "calc(1 + 1)" ) , "2" , "addition" )
20
20
t . equal ( reduceCssCalc ( "calc(1 - 1)" ) , "0" , "substraction" )
21
21
t . equal ( reduceCssCalc ( "calc(2 * 2)" ) , "4" , "multiplication" )
@@ -24,7 +24,7 @@ test("complete reduce for simple css calc()", function (t) {
24
24
t . end ( )
25
25
} )
26
26
27
- test ( "complete reduce for css calc() with a single unit" , function ( t ) {
27
+ test ( "complete reduce for css calc() with a single unit" , function ( t ) {
28
28
t . equal ( reduceCssCalc ( "calc(3px * 2 - 1px)" ) , "5px" , "px" )
29
29
t . equal ( reduceCssCalc ( "calc(3rem * 2 - 1rem)" ) , "5rem" , "rem" )
30
30
t . equal ( reduceCssCalc ( "calc(3em * 2 - 1em)" ) , "5em" , "em" )
@@ -33,13 +33,13 @@ test("complete reduce for css calc() with a single unit", function (t) {
33
33
t . end ( )
34
34
} )
35
35
36
- test ( "complete & accurate reduce for css calc() with percentages" , function ( t ) {
36
+ test ( "complete & accurate reduce for css calc() with percentages" , function ( t ) {
37
37
t . equal ( reduceCssCalc ( "calc(2 * 50%)" ) , "100%" , "integer * percentage" )
38
38
t . equal ( reduceCssCalc ( "calc(120% * 50%)" ) , "60%" , "percentage * percentage" )
39
39
t . end ( )
40
40
} )
41
41
42
- test ( "ignore value around css calc() functions " , function ( t ) {
42
+ test ( "ignore value around css calc() functions " , function ( t ) {
43
43
t . equal ( reduceCssCalc ( "calc(1 + 1) a" ) , "2 a" , "value after" )
44
44
t . equal ( reduceCssCalc ( "a calc(1 + 1)" ) , "a 2" , "value before" )
45
45
t . equal ( reduceCssCalc ( "calc(1 + 1) a calc(1 - 1)" ) , "2 a 0" , "value between 2 calc()" )
@@ -48,14 +48,14 @@ test("ignore value around css calc() functions ", function (t) {
48
48
t . end ( )
49
49
} )
50
50
51
- test ( "reduce complexe css calc()" , function ( t ) {
51
+ test ( "reduce complexe css calc()" , function ( t ) {
52
52
t . equal ( reduceCssCalc ( "calc(calc(100 + 10) + 1)" ) , "111" , "integer" )
53
53
t . equal ( reduceCssCalc ( "calc(calc(calc(1rem * 0.75) * 1.5) - 1rem)" ) , "0.125rem" , "with a single unit" )
54
54
t . equal ( reduceCssCalc ( "calc(calc(calc(1rem * 0.75) * 1.5) - 1px)" ) , "calc(1.125rem - 1px)" , "multiple units" )
55
55
t . end ( )
56
56
} )
57
57
58
- test ( "reduce prefixed css calc()" , function ( t ) {
58
+ test ( "reduce prefixed css calc()" , function ( t ) {
59
59
t . equal ( reduceCssCalc ( "-webkit-calc(120% * 50%)" ) , "60%" , "-webkit, complete reduce" )
60
60
t . equal ( reduceCssCalc ( "-webkit-calc(100% - 2em)" ) , "-webkit-calc(100% - 2em)" , "-webkit, multiple unit" )
61
61
0 commit comments