Download wp-calypso/client/my-sites/checkout/src/test/hydrate-nested-object.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/my-sites/checkout/src/test/hydrate-nested-object.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/my-sites/checkout/src/test/hydrate-nested-object.js
-
curl -L -o hydrate-nested-object.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/my-sites/checkout/src/test/hydrate-nested-object.js
1.17 kB
| import { hydrateNestedObject } from '../lib/contact-validation'; | |
| describe( 'hydrateNestedObject', () => { | |
| it( 'transforms flat object into flat object', () => { | |
| const actual = hydrateNestedObject( {}, [ 'foo' ], 'value' ); | |
| expect( actual ).toEqual( { foo: 'value' } ); | |
| } ); | |
| it( 'transforms flat object into flat object with array values', () => { | |
| const actual = hydrateNestedObject( {}, [ 'foo' ], [ 'value' ] ); | |
| expect( actual ).toEqual( { foo: [ 'value' ] } ); | |
| } ); | |
| it( 'transforms nested object into nested object', () => { | |
| const actual = hydrateNestedObject( {}, [ 'foo', 'bar' ], 'value' ); | |
| expect( actual ).toEqual( { foo: { bar: 'value' } } ); | |
| } ); | |
| it( 'transforms nested object into nested object merged with original object', () => { | |
| const actual = hydrateNestedObject( { name: 'human' }, [ 'foo', 'bar' ], 'value' ); | |
| expect( actual ).toEqual( { name: 'human', foo: { bar: 'value' } } ); | |
| } ); | |
| it( 'transforms deeply nested object into nested object', () => { | |
| const actual = hydrateNestedObject( {}, [ 'foo', 'bar', 'baz', 'biz' ], 'value' ); | |
| expect( actual ).toEqual( { foo: { bar: { baz: { biz: 'value' } } } } ); | |
| } ); | |
| } ); | |