@@ -2,7 +2,7 @@ const assert = require('assert');
2
2
const attributesToProps = require ( '../lib/attributes-to-props' ) ;
3
3
const utilities = require ( '../lib/utilities' ) ;
4
4
5
- describe ( 'attributesToProps ' , ( ) => {
5
+ describe ( 'attributes-to-props ' , ( ) => {
6
6
describe ( 'HTML' , ( ) => {
7
7
it ( 'converts attributes to React props' , ( ) => {
8
8
assert . deepEqual (
@@ -60,7 +60,7 @@ describe('attributesToProps', () => {
60
60
) ;
61
61
} ) ;
62
62
63
- it ( 'keeps `data-` and `aria-` attributes as is' , ( ) => {
63
+ it ( 'keeps `data-* ` and `aria-* ` attributes as is' , ( ) => {
64
64
assert . deepEqual (
65
65
attributesToProps ( {
66
66
'data-foo' : 'bar' ,
@@ -248,35 +248,56 @@ describe('attributesToProps', () => {
248
248
} ) ;
249
249
} ) ;
250
250
251
- describe ( 'when utilties.PRESERVE_CUSTOM_ATTRIBUTES=false' , ( ) => {
252
- const { PRESERVE_CUSTOM_ATTRIBUTES } = utilities ;
253
-
254
- before ( ( ) => {
255
- utilities . PRESERVE_CUSTOM_ATTRIBUTES = false ;
251
+ describe ( 'custom' , ( ) => {
252
+ it ( 'converts attributes named after Object properties' , ( ) => {
253
+ // handled as custom attributes
254
+ const attributes = {
255
+ __defineGetter__ : '' ,
256
+ __defineSetter__ : '' ,
257
+ __lookupGetter__ : '' ,
258
+ __lookupSetter__ : '' ,
259
+ __proto__ : '' ,
260
+ constructor : '' ,
261
+ hasOwnProperty : '' ,
262
+ isPrototypeOf : '' ,
263
+ propertyIsEnumerable : '' ,
264
+ toLocaleString : '' ,
265
+ toString : '' ,
266
+ valueOf : ''
267
+ } ;
268
+ assert . deepEqual ( attributesToProps ( attributes ) , attributes ) ;
256
269
} ) ;
257
270
258
- after ( ( ) => {
259
- utilities . PRESERVE_CUSTOM_ATTRIBUTES = PRESERVE_CUSTOM_ATTRIBUTES ;
260
- } ) ;
271
+ describe ( 'when utilties.PRESERVE_CUSTOM_ATTRIBUTES=false' , ( ) => {
272
+ const { PRESERVE_CUSTOM_ATTRIBUTES } = utilities ;
261
273
262
- it ( 'omits unknown attributes' , ( ) => {
263
- assert . deepEqual (
264
- attributesToProps ( {
265
- unknownAttribute : 'someValue'
266
- } ) ,
267
- { }
268
- ) ;
269
- } ) ;
274
+ before ( ( ) => {
275
+ utilities . PRESERVE_CUSTOM_ATTRIBUTES = false ;
276
+ } ) ;
270
277
271
- it ( 'omits incorrectly capitalized attributes' , ( ) => {
272
- assert . deepEqual (
273
- attributesToProps ( {
274
- 'XLINK:HREF' : '#' ,
275
- YChannelSelector : 'G' ,
276
- ZoomAndPan : 'disable'
277
- } ) ,
278
- { }
279
- ) ;
278
+ after ( ( ) => {
279
+ utilities . PRESERVE_CUSTOM_ATTRIBUTES = PRESERVE_CUSTOM_ATTRIBUTES ;
280
+ } ) ;
281
+
282
+ it ( 'omits unknown attributes' , ( ) => {
283
+ assert . deepEqual (
284
+ attributesToProps ( {
285
+ unknownAttribute : 'someValue'
286
+ } ) ,
287
+ { }
288
+ ) ;
289
+ } ) ;
290
+
291
+ it ( 'omits incorrectly capitalized attributes' , ( ) => {
292
+ assert . deepEqual (
293
+ attributesToProps ( {
294
+ 'XLINK:HREF' : '#' ,
295
+ YChannelSelector : 'G' ,
296
+ ZoomAndPan : 'disable'
297
+ } ) ,
298
+ { }
299
+ ) ;
300
+ } ) ;
280
301
} ) ;
281
302
} ) ;
282
303
} ) ;
0 commit comments