Son CV dans un terminal web en Javascript! https://terminal-cv.gregandev.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
terminal-cv/node_modules/msgpackr/tests/test-compatibility.cjs

64 lines
2.1 KiB

const data = require('./example4.json');
const { pack, unpack, Packr } = require('msgpackr/pack');
const chai = require('chai');
function tryRequire(module) {
try {
return require(module)
} catch(error) {
console.log(error)
}
}
//if (typeof chai === 'undefined') { chai = require('chai') }
const assert = chai.assert
//if (typeof msgpackr === 'undefined') { msgpackr = require('..') }
var msgpack_msgpack = tryRequire('@msgpack/msgpack');
var msgpack_lite = tryRequire('msgpack-lite');
var msgpack = tryRequire('msgpack');
const addCompatibilitySuite = (data) => () => {
if (msgpack_msgpack) {
test('from @msgpack/msgpack', function(){
var serialized = msgpack_msgpack.encode(data)
var deserialized = unpack(serialized)
assert.deepEqual(deserialized, data)
})
test('to @msgpack/msgpack', function(){
var serialized = pack(data)
var deserialized = msgpack_msgpack.decode(serialized)
assert.deepEqual(deserialized, data)
})
}
if (msgpack_lite) {
test('from msgpack-lite', function(){
var serialized = msgpack_lite.encode(data)
var deserialized = unpack(serialized)
assert.deepEqual(deserialized, data)
})
test('to msgpack-lite', function(){
var serialized = pack(data)
var deserialized = msgpack_lite.decode(serialized)
assert.deepEqual(deserialized, data)
})
}
if (msgpack) {
test.skip('from msgpack', function(){
var serialized = msgpack.pack(data)
var deserialized = unpack(serialized)
assert.deepEqual(deserialized, data)
})
test('to msgpack', function(){
var serialized = pack(data)
var deserialized = msgpack.unpack(serialized)
assert.deepEqual(deserialized, data)
})
}
}
suite('msgpackr compatibility tests (example)', addCompatibilitySuite(require('./example.json')))
suite('msgpackr compatibility tests (example4)', addCompatibilitySuite(require('./example4.json')))
suite('msgpackr compatibility tests (example5)', addCompatibilitySuite(require('./example5.json')))
suite.skip('msgpackr compatibility tests with dates', addCompatibilitySuite({ date: new Date() }))