Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tape('unpackEnvelope name parsing', t => {
const notype = unpackEnvelope({type: 'foo', data: {a: 42}});
t.equals(notype.namespace, 'foo');
t.equals(notype.type, '');
const empty = unpackEnvelope({type: '', data: {a: 42}});
t.equals(empty.namespace, '');
t.equals(empty.type, '');
const nonXVIZ = unpackEnvelope({type: 'foo/bar', data: {a: 42}});
t.equals(nonXVIZ.namespace, 'foo');
t.equals(nonXVIZ.type, 'bar');
const leadingSlash = unpackEnvelope({type: '/foo/bar', data: {a: 42}});
t.equals(leadingSlash.namespace, '');
t.equals(leadingSlash.type, 'foo/bar');
t.end();
tape('unpackEnvelope xviz', t => {
const enveloped = {
type: 'xviz/state_update',
data: {a: 42}
};
const expected = {
namespace: 'xviz',
type: 'state_update',
data: enveloped.data
};
t.deepEquals(unpackEnvelope(enveloped), expected);
t.end();
});
tape('unpackEnvelope name parsing', t => {
const notype = unpackEnvelope({type: 'foo', data: {a: 42}});
t.equals(notype.namespace, 'foo');
t.equals(notype.type, '');
const empty = unpackEnvelope({type: '', data: {a: 42}});
t.equals(empty.namespace, '');
t.equals(empty.type, '');
const nonXVIZ = unpackEnvelope({type: 'foo/bar', data: {a: 42}});
t.equals(nonXVIZ.namespace, 'foo');
t.equals(nonXVIZ.type, 'bar');
const leadingSlash = unpackEnvelope({type: '/foo/bar', data: {a: 42}});
t.equals(leadingSlash.namespace, '');
t.equals(leadingSlash.type, 'foo/bar');
t.end();
});
tape('unpackEnvelope name parsing', t => {
const notype = unpackEnvelope({type: 'foo', data: {a: 42}});
t.equals(notype.namespace, 'foo');
t.equals(notype.type, '');
const empty = unpackEnvelope({type: '', data: {a: 42}});
t.equals(empty.namespace, '');
t.equals(empty.type, '');
const nonXVIZ = unpackEnvelope({type: 'foo/bar', data: {a: 42}});
t.equals(nonXVIZ.namespace, 'foo');
t.equals(nonXVIZ.type, 'bar');
const leadingSlash = unpackEnvelope({type: '/foo/bar', data: {a: 42}});
t.equals(leadingSlash.namespace, '');
t.equals(leadingSlash.type, 'foo/bar');
t.end();
});
tape('unpackEnvelope name parsing', t => {
const notype = unpackEnvelope({type: 'foo', data: {a: 42}});
t.equals(notype.namespace, 'foo');
t.equals(notype.type, '');
const empty = unpackEnvelope({type: '', data: {a: 42}});
t.equals(empty.namespace, '');
t.equals(empty.type, '');
const nonXVIZ = unpackEnvelope({type: 'foo/bar', data: {a: 42}});
t.equals(nonXVIZ.namespace, 'foo');
t.equals(nonXVIZ.type, 'bar');
const leadingSlash = unpackEnvelope({type: '/foo/bar', data: {a: 42}});
t.equals(leadingSlash.namespace, '');
t.equals(leadingSlash.type, 'foo/bar');
t.end();
});