mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
describe('Gun', function(){
|
|
var Gun = require('../gun2');
|
|
|
|
it('ify', function(){return;
|
|
var data, test;
|
|
|
|
data = {a: false, b: true, c: 0, d: 1, e: '', f: 'g', h: null};
|
|
test = Gun.ify(data);
|
|
expect(test.err).to.not.be.ok();
|
|
|
|
data = {};
|
|
data.a = {x: 1, y: 2, z: 3}
|
|
data.b = {m: 'n', o: 'p', q: 'r', s: 't'};
|
|
data.a.kid = data.b;
|
|
data.b.parent = data.a;
|
|
data.loop = [data.b, data.a.kid, data];
|
|
test = Gun.ify(data);
|
|
expect(test.err).to.not.be.ok();
|
|
|
|
data = {_: {'#': 'shhh', meta: {yay: 1}}, sneak: true};
|
|
test = Gun.ify(data);
|
|
expect(test.err).to.not.be.ok(); // metadata needs to be stored, but it can't be used for data.
|
|
|
|
data = {};
|
|
data.sneak = false;
|
|
data.both = {inside: 'meta data'};
|
|
data._ = {'#': 'shhh', data: {yay: 1}, spin: data.both};
|
|
test = Gun.ify(data);
|
|
expect(test.err.meta).to.be.ok(); // TODO: Fail: this passes, somehow? Fix ify code!
|
|
|
|
data = {one: {two: [9, 8, 7, 6, 5]}};
|
|
test = Gun.ify(data);
|
|
expect(test.err.array).to.be.ok();
|
|
|
|
data = {z: undefined, x: 'bye'};
|
|
test = Gun.ify(data);
|
|
expect(test.err.invalid).to.be.ok();
|
|
|
|
data = {a: NaN, b: 2};
|
|
test = Gun.ify(data);
|
|
expect(test.err.invalid).to.be.ok();
|
|
|
|
data = {a: 1, b: Infinity};
|
|
test = Gun.ify(data);
|
|
expect(test.err.invalid).to.be.ok();
|
|
|
|
data = {c: function(){}, d: 'hi'};
|
|
test = Gun.ify(data);
|
|
expect(test.err.invalid).to.be.ok();
|
|
|
|
console.log(test.nodes);
|
|
});
|
|
|
|
it('ify', function(){
|
|
var graph, prime;
|
|
|
|
graph = Gun.ify({a: false, b: true, c: 0, d: 1, e: '', f: 'g', h: null}).nodes;
|
|
prime = Gun.ify({h: 9, i: 'foo', j: 'k', l: 'bar', m: 'Mark', n: 'Nadal'}).nodes;
|
|
|
|
Gun.union(graph, prime);
|
|
});
|
|
|
|
}); |