@@ -2,7 +2,7 @@ const assert = require('assert');
22const attributesToProps = require ( '../lib/attributes-to-props' ) ;
33const utilities = require ( '../lib/utilities' ) ;
44
5- describe ( 'attributesToProps ' , ( ) => {
5+ describe ( 'attributes-to-props ' , ( ) => {
66 describe ( 'HTML' , ( ) => {
77 it ( 'converts attributes to React props' , ( ) => {
88 assert . deepEqual (
@@ -60,7 +60,7 @@ describe('attributesToProps', () => {
6060 ) ;
6161 } ) ;
6262
63- it ( 'keeps `data-` and `aria-` attributes as is' , ( ) => {
63+ it ( 'keeps `data-* ` and `aria-* ` attributes as is' , ( ) => {
6464 assert . deepEqual (
6565 attributesToProps ( {
6666 'data-foo' : 'bar' ,
@@ -248,35 +248,56 @@ describe('attributesToProps', () => {
248248 } ) ;
249249 } ) ;
250250
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 ) ;
256269 } ) ;
257270
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 ;
261273
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+ } ) ;
270277
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+ } ) ;
280301 } ) ;
281302 } ) ;
282303} ) ;
0 commit comments