11const data = require ( './example4.json' ) ;
2- const { pack, unpack } = require ( 'msgpackr/pack' ) ;
2+ const { pack, unpack, Packr } = require ( 'msgpackr/pack' ) ;
33const chai = require ( 'chai' ) ;
44
55function tryRequire ( module ) {
66 try {
77 return require ( module )
88 } catch ( error ) {
9+ console . log ( error )
910 }
1011}
1112//if (typeof chai === 'undefined') { chai = require('chai') }
1213const assert = chai . assert
1314//if (typeof msgpackr === 'undefined') { msgpackr = require('..') }
1415var msgpack_msgpack = tryRequire ( '@msgpack/msgpack' ) ;
1516var msgpack_lite = tryRequire ( 'msgpack-lite' ) ;
17+ var msgpack = tryRequire ( 'msgpack' ) ;
1618
1719const addCompatibilitySuite = ( data ) => ( ) => {
1820 if ( msgpack_msgpack ) {
@@ -41,8 +43,22 @@ const addCompatibilitySuite = (data) => () => {
4143 assert . deepEqual ( deserialized , data )
4244 } )
4345 }
46+ if ( msgpack ) {
47+ test . skip ( 'from msgpack' , function ( ) {
48+ var serialized = msgpack . pack ( data )
49+ var deserialized = unpack ( serialized )
50+ assert . deepEqual ( deserialized , data )
51+ } )
52+
53+ test ( 'to msgpack' , function ( ) {
54+ var serialized = pack ( data )
55+ var deserialized = msgpack . unpack ( serialized )
56+ assert . deepEqual ( deserialized , data )
57+ } )
58+ }
4459}
4560
4661suite ( 'msgpackr compatibility tests (example)' , addCompatibilitySuite ( require ( './example.json' ) ) )
4762suite ( 'msgpackr compatibility tests (example4)' , addCompatibilitySuite ( require ( './example4.json' ) ) )
48- suite ( 'msgpackr compatibility tests (example5)' , addCompatibilitySuite ( require ( './example5.json' ) ) )
63+ suite ( 'msgpackr compatibility tests (example5)' , addCompatibilitySuite ( require ( './example5.json' ) ) )
64+ suite . skip ( 'msgpackr compatibility tests with dates' , addCompatibilitySuite ( { date : new Date ( ) } ) )
0 commit comments