reign
Version:
A persistent, typed-objects implementation.
48 lines (35 loc) • 1.16 kB
JavaScript
;
var _bluebird = require("bluebird");
var _ = require("./");
var _backing = require("backing");
var _backing2 = _interopRequireDefault(_backing);
var _symbols = require("./symbols");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describeRealm('Realm', function (options) {
let realm;
let other;
let T;
before(() => {
realm = options.realm;
T = realm.T;
});
it('should set a key / value', function () {
realm.set('foo', 'bar');
});
it('should get a key / value', function () {
realm.get('foo').should.equal('bar');
});
it('should load another copy of the realm', (0, _bluebird.coroutine)(function* () {
other = new _.Realm(new _backing2.default(options.backingOptions));
yield other.init();
}));
it('should get the key / value', function () {
other.get('foo').should.equal('bar');
});
it('should share key / values across realm instances', function () {
other.set('foo', 'baz');
realm.set('obj', { a: 1, b: 2, c: 3 });
realm.get('foo').should.equal('baz');
other.get('obj').should.eql({ a: 1, b: 2, c: 3 });
});
});