Skip to content

Latest commit

 

History

History
105 lines (79 loc) · 2.14 KB

docs.md

File metadata and controls

105 lines (79 loc) · 2.14 KB

TOC

entity

#digest

should wrap param object with method matching calling method name and add to array of newEvents.

var param = {
          data: 'data'
        };

      var test = new TestEntity(),
          data = { test: 'data' };

      test.method(data);

      test.newEvents.length.should.equal(1);
      test.newEvents[0].method.should.equal('method');
      test.newEvents[0].data.should.equal(data);

#merge

should marge a snapshot into the current object, overwriting any common properties.

var snapshot = {
          property: true,
          property2: true
        };

      var test = new TestEntity();

      test.merge(snapshot);

      test.property.should.equal(true);
      test.property2.should.equal(true);

#replay

should throw an entity error with name of model when attempting to replay a method an entity does not implement.

var events = [
        {
          method: 'someMethod',
          data: { some: 'param' }
        }
      ];

      var test = new TestEntity();

      (function () {
        test.replay(events);
      }).should.throw('method \'someMethod\' does not exist on model \'TestEntity\'');

#snapshot

should return object with current state of the entity.

;
      var param = {
        data: 'data'
      };

      var test = new TestEntity(),
          data = { data: 'data' };

      test.method(data);

      var snapshot = test.snapshot();

      snapshot.property2.should.equal(data.data);
      snapshot.snapshotVersion.should.equal(1);
      snapshot.version.should.equal(1);

value

should be immutable.

var value = Value({
        property: 'value'
      });

      value.should.have.property('property', 'value');

      value.property = 'new value';

      value.should.have.property('property', 'value');