@@ -62,31 +62,31 @@ exports.filesize = {
62
62
base10 : function ( test ) {
63
63
test . expect ( 25 ) ;
64
64
65
- test . equal ( filesize ( this . kilobit , { base : 10 } ) , "500 B" , "Should be '500 B'" ) ;
66
- test . equal ( filesize ( this . kilobit , { base : 10 , round : 1 } ) , "500 B" , "Should be '500 B'" ) ;
67
- test . equal ( filesize ( this . kilobit , { base : 10 , round : 1 , spacer : "" } ) , "500B" , "Should be '500B'" ) ;
68
- test . equal ( filesize ( this . kilobit , { base : 10 , bits : true } ) , "4 Kibit" , "Should be '4 Kibit'" ) ;
69
- test . equal ( filesize ( this . kilobit , { base : 10 , round : 1 , bits : true } ) , "4 Kibit" , "Should be '4 Kibit'" ) ;
70
- test . equal ( filesize ( this . kibibyte , { base : 10 } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
71
- test . equal ( filesize ( this . kibibyte , { base : 10 , round : 1 } ) , "1 KiB" , "Should be '1 KiB'" ) ;
72
- test . equal ( filesize ( this . kibibyte , { base : 10 , round : 1 , spacer : "" } ) , "1KiB" , "Should be '1KiB'" ) ;
73
- test . equal ( filesize ( this . kibibyte , { base : 10 , bits : true } ) , "8.19 Kibit" , "Should be '8.19 Kibit'" ) ;
74
- test . equal ( filesize ( this . kibibyte , { base : 10 , round : 1 , bits : true } ) , "8.2 Kibit" , "Should be '8.2 Kibit'" ) ;
75
- test . equal ( filesize ( this . neg , { base : 10 } ) , "-1.02 KiB" , "Should be '-1.02 KiB'" ) ;
76
- test . equal ( filesize ( this . neg , { base : 10 , round : 1 } ) , "-1 KiB" , "Should be '-1 KiB'" ) ;
77
- test . equal ( filesize ( this . neg , { base : 10 , round : 1 , spacer : "" } ) , "-1KiB" , "Should be '-1KiB'" ) ;
78
- test . equal ( filesize ( this . neg , { base : 10 , bits : true } ) , "-8.19 Kibit" , "Should be '-8.19 Kibit'" ) ;
79
- test . equal ( filesize ( this . neg , { base : 10 , round : 1 , bits : true } ) , "-8.2 Kibit" , "Should be '-8.2 Kibit'" ) ;
80
- test . equal ( filesize ( this . byte , { base : 10 } ) , "1 B" , "Should be '1 B'" ) ;
81
- test . equal ( filesize ( this . byte , { base : 10 , round : 1 } ) , "1 B" , "Should be '1 B'" ) ;
82
- test . equal ( filesize ( this . byte , { base : 10 , round : 1 , spacer : "" } ) , "1B" , "Should be '1B'" ) ;
83
- test . equal ( filesize ( this . byte , { base : 10 , bits : true } ) , "8 bit" , "Should be '8 bit'" ) ;
84
- test . equal ( filesize ( this . byte , { base : 10 , round : 1 , bits : true } ) , "8 bit" , "Should be '8 bit'" ) ;
85
- test . equal ( filesize ( this . zero , { base : 10 } ) , "0 B" , "Should be '0 B'" ) ;
86
- test . equal ( filesize ( this . zero , { base : 10 , round : 1 } ) , "0 B" , "Should be '0 B'" ) ;
87
- test . equal ( filesize ( this . zero , { base : 10 , round : 1 , spacer : "" } ) , "0B" , "Should be '0B'" ) ;
88
- test . equal ( filesize ( this . zero , { base : 10 , bits : true } ) , "0 bit" , "Should be '0 bit'" ) ;
89
- test . equal ( filesize ( this . zero , { base : 10 , round : 1 , bits : true } ) , "0 bit" , "Should be '0 bit'" ) ;
65
+ test . equal ( filesize ( this . kilobit ) , "500 B" , "Should be '500 B'" ) ;
66
+ test . equal ( filesize ( this . kilobit , { round : 1 } ) , "500 B" , "Should be '500 B'" ) ;
67
+ test . equal ( filesize ( this . kilobit , { round : 1 , spacer : "" } ) , "500B" , "Should be '500B'" ) ;
68
+ test . equal ( filesize ( this . kilobit , { bits : true } ) , "4 Kibit" , "Should be '4 Kibit'" ) ;
69
+ test . equal ( filesize ( this . kilobit , { round : 1 , bits : true } ) , "4 Kibit" , "Should be '4 Kibit'" ) ;
70
+ test . equal ( filesize ( this . kibibyte ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
71
+ test . equal ( filesize ( this . kibibyte , { round : 1 } ) , "1 KiB" , "Should be '1 KiB'" ) ;
72
+ test . equal ( filesize ( this . kibibyte , { round : 1 , spacer : "" } ) , "1KiB" , "Should be '1KiB'" ) ;
73
+ test . equal ( filesize ( this . kibibyte , { bits : true } ) , "8.19 Kibit" , "Should be '8.19 Kibit'" ) ;
74
+ test . equal ( filesize ( this . kibibyte , { round : 1 , bits : true } ) , "8.2 Kibit" , "Should be '8.2 Kibit'" ) ;
75
+ test . equal ( filesize ( this . neg ) , "-1.02 KiB" , "Should be '-1.02 KiB'" ) ;
76
+ test . equal ( filesize ( this . neg , { round : 1 } ) , "-1 KiB" , "Should be '-1 KiB'" ) ;
77
+ test . equal ( filesize ( this . neg , { round : 1 , spacer : "" } ) , "-1KiB" , "Should be '-1KiB'" ) ;
78
+ test . equal ( filesize ( this . neg , { bits : true } ) , "-8.19 Kibit" , "Should be '-8.19 Kibit'" ) ;
79
+ test . equal ( filesize ( this . neg , { round : 1 , bits : true } ) , "-8.2 Kibit" , "Should be '-8.2 Kibit'" ) ;
80
+ test . equal ( filesize ( this . byte ) , "1 B" , "Should be '1 B'" ) ;
81
+ test . equal ( filesize ( this . byte , { round : 1 } ) , "1 B" , "Should be '1 B'" ) ;
82
+ test . equal ( filesize ( this . byte , { round : 1 , spacer : "" } ) , "1B" , "Should be '1B'" ) ;
83
+ test . equal ( filesize ( this . byte , { bits : true } ) , "8 bit" , "Should be '8 bit'" ) ;
84
+ test . equal ( filesize ( this . byte , { round : 1 , bits : true } ) , "8 bit" , "Should be '8 bit'" ) ;
85
+ test . equal ( filesize ( this . zero ) , "0 B" , "Should be '0 B'" ) ;
86
+ test . equal ( filesize ( this . zero , { round : 1 } ) , "0 B" , "Should be '0 B'" ) ;
87
+ test . equal ( filesize ( this . zero , { round : 1 , spacer : "" } ) , "0B" , "Should be '0B'" ) ;
88
+ test . equal ( filesize ( this . zero , { bits : true } ) , "0 bit" , "Should be '0 bit'" ) ;
89
+ test . equal ( filesize ( this . zero , { round : 1 , bits : true } ) , "0 bit" , "Should be '0 bit'" ) ;
90
90
test . done ( ) ;
91
91
} ,
92
92
invalid : function ( test ) {
@@ -98,65 +98,65 @@ exports.filesize = {
98
98
} ,
99
99
symbols : function ( test ) {
100
100
test . expect ( 2 ) ;
101
- test . equal ( filesize ( this . byte , { base : 10 , symbols : { B : "Б" } } ) , "1 Б" , "Should be '1 Б'" ) ;
102
- test . equal ( filesize ( this . kibibyte , { base : 10 , symbols : { B : "Б" } } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
101
+ test . equal ( filesize ( this . byte , { symbols : { B : "Б" } } ) , "1 Б" , "Should be '1 Б'" ) ;
102
+ test . equal ( filesize ( this . kibibyte , { symbols : { B : "Б" } } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
103
103
test . done ( ) ;
104
104
} ,
105
105
partial : function ( test ) {
106
106
test . expect ( 1 ) ;
107
- test . size = filesize . partial ( { base : 10 , exponent : 0 } ) ;
107
+ test . size = filesize . partial ( { exponent : 0 } ) ;
108
108
test . equal ( test . size ( this . kibibyte ) , "1024 B" , "Should be '1024 B'" ) ;
109
109
test . done ( ) ;
110
110
} ,
111
111
bits : function ( test ) {
112
112
test . expect ( 3 ) ;
113
- test . equal ( filesize ( 124 , { bits : true , base : 10 } ) , "992 bit" , "Should be '992 bit'" ) ;
114
- test . equal ( filesize ( 125 , { bits : true , base : 10 } ) , "1 Kibit" , "Should be '1 Kibit'" ) ;
115
- test . equal ( filesize ( 126 , { bits : true , base : 10 } ) , "1.01 Kibit" , "Should be '1.01 Kibit'" ) ;
113
+ test . equal ( filesize ( 124 , { bits : true } ) , "992 bit" , "Should be '992 bit'" ) ;
114
+ test . equal ( filesize ( 125 , { bits : true } ) , "1 Kibit" , "Should be '1 Kibit'" ) ;
115
+ test . equal ( filesize ( 126 , { bits : true } ) , "1.01 Kibit" , "Should be '1.01 Kibit'" ) ;
116
116
test . done ( ) ;
117
117
} ,
118
118
fullform : function ( test ) {
119
119
test . expect ( 10 ) ;
120
- test . equal ( filesize ( 0 , { base : 10 , fullform : true } ) , "0 bytes" , "Should be '0 bytes'" ) ;
121
- test . equal ( filesize ( 0 , { base : 10 , fullform : true , output : "object" } ) . unit , "B" , "Should be 'B'" ) ;
122
- test . equal ( filesize ( 1 , { base : 10 , bits : true , fullform : true } ) , "8 bits" , "Should be '8 bits'" ) ;
123
- test . equal ( filesize ( 1 , { base : 10 , fullform : true } ) , "1 byte" , "Should be '1 byte'" ) ;
124
- test . equal ( filesize ( this . kibibyte , { base : 10 , standard : "jedec" , fullform : true } ) , "1.02 kilobytes" , "Should be '1.02 kilobytes'" ) ;
125
- test . equal ( filesize ( this . kibibyte , { base : 10 , fullform : true } ) , "1.02 kibibytes" , "Should be '1.02 kibibytes'" ) ;
120
+ test . equal ( filesize ( 0 , { fullform : true } ) , "0 bytes" , "Should be '0 bytes'" ) ;
121
+ test . equal ( filesize ( 0 , { fullform : true , output : "object" } ) . unit , "B" , "Should be 'B'" ) ;
122
+ test . equal ( filesize ( 1 , { bits : true , fullform : true } ) , "8 bits" , "Should be '8 bits'" ) ;
123
+ test . equal ( filesize ( 1 , { fullform : true } ) , "1 byte" , "Should be '1 byte'" ) ;
124
+ test . equal ( filesize ( this . kibibyte , { standard : "jedec" , fullform : true } ) , "1.02 kilobytes" , "Should be '1.02 kilobytes'" ) ;
125
+ test . equal ( filesize ( this . kibibyte , { fullform : true } ) , "1.02 kibibytes" , "Should be '1.02 kibibytes'" ) ;
126
126
test . equal ( filesize ( this . kibibyte , { base : 2 , fullform : true } ) , "1 kibibyte" , "Should be '1 kibibyte'" ) ;
127
127
test . equal ( filesize ( this . kibibyte , { base : 2 , fullform : true , output : "object" } ) . unit , "KiB" , "Should be 'KiB'" ) ;
128
128
test . equal ( filesize ( this . kibibyte * 1.3 , {
129
129
base : 2 ,
130
130
standard : "iec" ,
131
131
fullform : true
132
132
} ) , "1.3 kibibytes" , "Should be '1.3 kibibytes'" ) ;
133
- test . equal ( filesize ( 0 , { base : 10 , fullform : true , fullforms : [ "байт" ] } ) , "0 байт" , "Should be '0 байт'" ) ;
133
+ test . equal ( filesize ( 0 , { fullform : true , fullforms : [ "байт" ] } ) , "0 байт" , "Should be '0 байт'" ) ;
134
134
test . done ( ) ;
135
135
} ,
136
136
exponent : function ( test ) {
137
137
test . expect ( 2 ) ;
138
- test . equal ( filesize ( 0 , { base : 10 , exponent : 0 } ) , "0 B" , "Should be '0 B'" ) ;
139
- test . equal ( filesize ( 0 , { base : 10 , exponent : 2 } ) , "0 MiB" , "Should be '0 MiB'" ) ;
138
+ test . equal ( filesize ( 0 , { exponent : 0 } ) , "0 B" , "Should be '0 B'" ) ;
139
+ test . equal ( filesize ( 0 , { exponent : 2 } ) , "0 MiB" , "Should be '0 MiB'" ) ;
140
140
test . done ( ) ;
141
141
} ,
142
142
separator : function ( test ) {
143
143
test . expect ( 3 ) ;
144
- test . equal ( filesize ( 1040 , { base : 10 , separator : "" } ) , "1.04 KiB" , "Should be '1.04 KiB'" ) ;
145
- test . equal ( filesize ( 1040 , { base : 10 , separator : "," } ) , "1,04 KiB" , "Should be '1,04 KiB'" ) ;
146
- test . equal ( filesize ( 1040 , { base : 10 , separator : "," , round : 1 , pad : true } ) , "1,0 KiB" , "Should be '1,0 KiB'" ) ;
144
+ test . equal ( filesize ( 1040 , { separator : "" } ) , "1.04 KiB" , "Should be '1.04 KiB'" ) ;
145
+ test . equal ( filesize ( 1040 , { separator : "," } ) , "1,04 KiB" , "Should be '1,04 KiB'" ) ;
146
+ test . equal ( filesize ( 1040 , { separator : "," , round : 1 , pad : true } ) , "1,0 KiB" , "Should be '1,0 KiB'" ) ;
147
147
test . done ( ) ;
148
148
} ,
149
149
locale : function ( test ) {
150
150
test . expect ( 3 ) ;
151
- test . equal ( filesize ( 1040 , { base : 10 , locale : "" } ) , "1.04 KiB" , "Should be '1.04 KiB'" ) ;
152
- test . equal ( filesize ( 1040 , { base : 10 , locale : true } ) , Number ( 1.04 ) . toLocaleString ( ) + " KiB" , "Should be '" + Number ( 1.04 ) . toLocaleString ( ) + " KiB'" ) ;
153
- test . equal ( filesize ( 1040 , { base : 10 , locale : "de" } ) , Number ( 1.04 ) . toLocaleString ( "de" ) + " KiB" , "Should be '" + Number ( 1.04 ) . toLocaleString ( "de" ) + " KiB'" ) ;
151
+ test . equal ( filesize ( 1040 , { locale : "" } ) , "1.04 KiB" , "Should be '1.04 KiB'" ) ;
152
+ test . equal ( filesize ( 1040 , { locale : true } ) , Number ( 1.04 ) . toLocaleString ( ) + " KiB" , "Should be '" + Number ( 1.04 ) . toLocaleString ( ) + " KiB'" ) ;
153
+ test . equal ( filesize ( 1040 , { locale : "de" } ) , Number ( 1.04 ) . toLocaleString ( "de" ) + " KiB" , "Should be '" + Number ( 1.04 ) . toLocaleString ( "de" ) + " KiB'" ) ;
154
154
test . done ( ) ;
155
155
} ,
156
156
localeOptions : function ( test ) {
157
157
test . expect ( 4 ) ;
158
- test . equal ( filesize ( this . kibibyte , { base : 10 , locale : "de" } ) , Number ( 1.02 ) . toLocaleString ( "de" ) + " KiB" , "Should be '" + Number ( 1.02 ) . toLocaleString ( "de" ) + " KiB'" ) ;
159
- test . equal ( filesize ( this . kibibyte , { base : 10 , localeOptions : { minimumFractionDigits : 1 } } ) , Number ( 1.02 ) . toLocaleString ( undefined , { minimumFractionDigits : 1 } ) + " KiB" , "Should be '" + Number ( 1.02 ) . toLocaleString ( undefined , { minimumFractionDigits : 1 } ) + " KiB'" ) ;
158
+ test . equal ( filesize ( this . kibibyte , { locale : "de" } ) , Number ( 1.02 ) . toLocaleString ( "de" ) + " KiB" , "Should be '" + Number ( 1.02 ) . toLocaleString ( "de" ) + " KiB'" ) ;
159
+ test . equal ( filesize ( this . kibibyte , { localeOptions : { minimumFractionDigits : 1 } } ) , Number ( 1.02 ) . toLocaleString ( undefined , { minimumFractionDigits : 1 } ) + " KiB" , "Should be '" + Number ( 1.02 ) . toLocaleString ( undefined , { minimumFractionDigits : 1 } ) + " KiB'" ) ;
160
160
test . equal ( filesize ( this . kibibyte , {
161
161
base : 10 ,
162
162
locale : true ,
@@ -171,24 +171,24 @@ exports.filesize = {
171
171
} ,
172
172
roundingMethod : function ( test ) {
173
173
test . expect ( 9 ) ;
174
- test . equal ( filesize ( this . kibibyte , { base : 10 , roundingMethod : "round" } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
175
- test . equal ( filesize ( this . kibibyte , { base : 10 , roundingMethod : "floor" } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
176
- test . equal ( filesize ( this . kibibyte , { base : 10 , roundingMethod : "ceil" } ) , "1.03 KiB" , "Should be '1.03 KiB'" ) ;
177
- test . equal ( filesize ( this . kibibyte * 1.333 , { base : 10 , roundingMethod : "round" } ) , "1.36 KiB" , "Should be '1.36 KiB'" ) ;
178
- test . equal ( filesize ( this . kibibyte * 1.333 , { base : 10 , roundingMethod : "floor" } ) , "1.36 KiB" , "Should be '1.36 KiB'" ) ;
179
- test . equal ( filesize ( this . kibibyte * 1.333 , { base : 10 , roundingMethod : "ceil" } ) , "1.37 KiB" , "Should be '1.37 KiB'" ) ;
180
- test . equal ( filesize ( this . kibibyte * 1.456 , { base : 10 , round : 1 , roundingMethod : "round" } ) , "1.5 KiB" , "Should be '1.5 KiB'" ) ;
181
- test . equal ( filesize ( this . kibibyte * 1.456 , { base : 10 , round : 1 , roundingMethod : "floor" } ) , "1.4 KiB" , "Should be '1.4 KiB'" ) ;
182
- test . equal ( filesize ( this . kibibyte * 1.456 , { base : 10 , round : 1 , roundingMethod : "ceil" } ) , "1.5 KiB" , "Should be '1.5 KiB'" ) ;
174
+ test . equal ( filesize ( this . kibibyte , { roundingMethod : "round" } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
175
+ test . equal ( filesize ( this . kibibyte , { roundingMethod : "floor" } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
176
+ test . equal ( filesize ( this . kibibyte , { roundingMethod : "ceil" } ) , "1.03 KiB" , "Should be '1.03 KiB'" ) ;
177
+ test . equal ( filesize ( this . kibibyte * 1.333 , { roundingMethod : "round" } ) , "1.36 KiB" , "Should be '1.36 KiB'" ) ;
178
+ test . equal ( filesize ( this . kibibyte * 1.333 , { roundingMethod : "floor" } ) , "1.36 KiB" , "Should be '1.36 KiB'" ) ;
179
+ test . equal ( filesize ( this . kibibyte * 1.333 , { roundingMethod : "ceil" } ) , "1.37 KiB" , "Should be '1.37 KiB'" ) ;
180
+ test . equal ( filesize ( this . kibibyte * 1.456 , { round : 1 , roundingMethod : "round" } ) , "1.5 KiB" , "Should be '1.5 KiB'" ) ;
181
+ test . equal ( filesize ( this . kibibyte * 1.456 , { round : 1 , roundingMethod : "floor" } ) , "1.4 KiB" , "Should be '1.4 KiB'" ) ;
182
+ test . equal ( filesize ( this . kibibyte * 1.456 , { round : 1 , roundingMethod : "ceil" } ) , "1.5 KiB" , "Should be '1.5 KiB'" ) ;
183
183
test . done ( ) ;
184
184
} ,
185
185
precision : function ( test ) {
186
186
test . expect ( 5 ) ;
187
- test . equal ( filesize ( this . kibibyte * 1 , { base : 10 , precision : 3 } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
188
- test . equal ( filesize ( this . kibibyte * this . kibibyte * 10.25 , { base : 10 , precision : 3 } ) , "10.8 MiB" , "Should be '10.8 MiB'" ) ;
189
- test . equal ( filesize ( this . kibibyte * this . kibibyte * 10.25 , { base : 10 , precision : "x" } ) , "10.75 MiB" , "Should be '10.75 MiB'" ) ;
190
- test . equal ( filesize ( this . kibibyte * this . kibibyte * this . kibibyte , { base : 10 , precision : 3 } ) , "1.07 GiB" , "Should be '1.07 GiB'" ) ;
191
- test . equal ( filesize ( Math . pow ( this . kibibyte , 10 ) , { base : 10 , precision : 3 } ) , "1e+6 YiB" , "Should be '1e+6 YiB'" ) ;
187
+ test . equal ( filesize ( this . kibibyte * 1 , { precision : 3 } ) , "1.02 KiB" , "Should be '1.02 KiB'" ) ;
188
+ test . equal ( filesize ( this . kibibyte * this . kibibyte * 10.25 , { precision : 3 } ) , "10.8 MiB" , "Should be '10.8 MiB'" ) ;
189
+ test . equal ( filesize ( this . kibibyte * this . kibibyte * 10.25 , { precision : "x" } ) , "10.75 MiB" , "Should be '10.75 MiB'" ) ;
190
+ test . equal ( filesize ( this . kibibyte * this . kibibyte * this . kibibyte , { precision : 3 } ) , "1.07 GiB" , "Should be '1.07 GiB'" ) ;
191
+ test . equal ( filesize ( Math . pow ( this . kibibyte , 10 ) , { precision : 3 } ) , "1e+6 YiB" , "Should be '1e+6 YiB'" ) ;
192
192
test . done ( ) ;
193
193
} ,
194
194
defaults : function ( test ) {
0 commit comments