@@ -11,6 +11,8 @@ const CID = require('cids')
1111const f = require ( './utils/factory' ) ( )
1212const ipfsHttpClient = require ( '../src' )
1313
14+ const isReactNative = typeof navigator !== 'undefined' && navigator . product === 'ReactNative'
15+
1416let ipfs
1517
1618describe ( '.dag' , function ( ) {
@@ -21,7 +23,12 @@ describe('.dag', function () {
2123
2224 after ( ( ) => f . clean ( ) )
2325
24- it ( 'should be able to put and get a DAG node with format dag-pb' , async ( ) => {
26+ it ( 'should be able to put and get a DAG node with format dag-pb' , async function ( ) {
27+ if ( isReactNative ) {
28+ // React Native does not support constructing Blobs out of arrays
29+ return this . skip ( )
30+ }
31+
2532 const data = uint8ArrayFromString ( 'some data' )
2633 const node = new DAGNode ( data )
2734
@@ -36,7 +43,12 @@ describe('.dag', function () {
3643 expect ( result . value . Data ) . to . deep . equal ( data )
3744 } )
3845
39- it ( 'should be able to put and get a DAG node with format dag-cbor' , async ( ) => {
46+ it ( 'should be able to put and get a DAG node with format dag-cbor' , async function ( ) {
47+ if ( isReactNative ) {
48+ // React Native does not support constructing Blobs out of arrays
49+ return this . skip ( )
50+ }
51+
4052 const cbor = { foo : 'dag-cbor-bar' }
4153 let cid = await ipfs . dag . put ( cbor , { format : 'dag-cbor' , hashAlg : 'sha2-256' } )
4254
@@ -50,7 +62,9 @@ describe('.dag', function () {
5062 } )
5163
5264 it ( 'should be able to put and get a DAG node with format raw' , async ( ) => {
53- const node = uint8ArrayFromString ( 'some data' )
65+ const textData = 'some data'
66+ const rawData = uint8ArrayFromString ( textData )
67+ const node = isReactNative ? textData : rawData
5468 let cid = await ipfs . dag . put ( node , { format : 'raw' , hashAlg : 'sha2-256' } )
5569
5670 expect ( cid . codec ) . to . equal ( 'raw' )
@@ -59,7 +73,7 @@ describe('.dag', function () {
5973
6074 const result = await ipfs . dag . get ( cid )
6175
62- expect ( result . value ) . to . deep . equal ( node )
76+ expect ( result . value ) . to . deep . equal ( rawData )
6377 } )
6478
6579 it ( 'should error when missing DAG resolver for multicodec from requested CID' , async ( ) => {
@@ -100,7 +114,12 @@ describe('.dag', function () {
100114 expect ( askedToLoadFormat ) . to . be . true ( )
101115 } )
102116
103- it ( 'should allow formats to be specified without overwriting others' , async ( ) => {
117+ it ( 'should allow formats to be specified without overwriting others' , async function ( ) {
118+ if ( isReactNative ) {
119+ // React Native does not support constructing Blobs out of arrays
120+ return this . skip ( )
121+ }
122+
104123 const ipfs2 = ipfsHttpClient ( {
105124 url : `http://${ ipfs . apiHost } :${ ipfs . apiPort } ` ,
106125 ipld : {
0 commit comments