Skip to content

Commit

Permalink
MapperTest
Browse files Browse the repository at this point in the history
  • Loading branch information
emacsway committed Oct 21, 2018
1 parent ebf25f5 commit 8a94c4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
14 changes: 7 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ Store public API
:param options.pk: the name of Primary Key or list of names of composite Primary Key.\
Optional. The default value is 'id'.
:type options.pk: string or Array[string]
:param ObjectAccessor objectAccessor: an instance of :class:`ObjectAccessor`.
:param ObjectAccessor options.objectAccessor: an instance of :class:`ObjectAccessor`.
Optional. By default will be created on fly using ``options.pk``.
:param Array[string] options.indexes: the array of field names to be indexed for fast finding or instance of local store.\
Note, all field used by relations or primary key will be indexed automatically.\
Optional.
:type IStore localStore: an instance of :class:`IStore`. Optional.\
:type IStore options.localStore: an instance of :class:`IStore`. Optional.\
By default will be created on fly using ``options``
:param IStore remoteStore: an instance of :class:`IStore`. Optional.\
:param IStore options.remoteStore: an instance of :class:`IStore`. Optional.\
By default will be created on fly using ``options``
:param function model: the model constructor, which should be applied before to add object into the store.\
:param function options.model: the model constructor, which should be applied before to add object into the store.\
Can be usefull in combination with :func:`Store.prototype.decompose`.\
Optional. The default value is :class:`DefaultModel`
:param Mapper mapper: an instance of :class:`Mapper`. Optional.\
Optioans. By default will be created on fly using ``options.model``
:param Object relations: the dictionary describes the schema relations.
:param Mapper options.mapper: an instance of :class:`Mapper`. Optional.\
By default will be created on fly using ``options.model``
:param Object options.relations: the dictionary describes the schema relations.

The format of ``options.relations`` argument::

Expand Down
15 changes: 13 additions & 2 deletions tests/unit/mapper/MapperTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ registerSuite('Mapper', () => {

return {
beforeEach() {
mapper = new store.Mapper();
mapper = new store.Mapper({
fields: [
new store.Field('id'),
new store.RenamedField('a', 'aRenamed'),
new store.Field(
'point',
(record) => new Point(record['x'], record['y']),
(value) => ({x: value['x'], y: value['y']}),
(error) => [error.x, error.y]
)
]
});
},
'TestModel': {
'should map point'() {
Expand All @@ -43,7 +54,7 @@ registerSuite('Mapper', () => {
x: 5,
y: 6
});
assert.deepEqual(obj, new TestModel(1, 2, newPoint(5, 6)));
assert.deepEqual(obj, new TestModel(1, 2, new Point(5, 6)));
}
}
};
Expand Down

0 comments on commit 8a94c4f

Please sign in to comment.