resourcerer 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/collection.js CHANGED
@@ -471,7 +471,7 @@ export default class Collection {
471
471
  return attrs;
472
472
  }
473
473
 
474
- return new this.Model(attrs, {...options, collection: this});
474
+ return new this.Model(attrs, {...this.urlOptions, ...options, collection: this});
475
475
  }
476
476
 
477
477
  /**
package/lib/model.js CHANGED
@@ -3,6 +3,16 @@ import {isDeepEqual, result, uniqueId, urlError} from './utils';
3
3
  import Events from './events';
4
4
  import sync from './sync';
5
5
 
6
+ const RESERVED_OPTION_KEYS = [
7
+ 'Model',
8
+ 'comparator',
9
+ 'parse',
10
+ 'collection',
11
+ 'silent',
12
+ 'method',
13
+ 'unset'
14
+ ];
15
+
6
16
  /**
7
17
  * The Model class should be extended for any resource that is singular, as in not a list of items.
8
18
  * It is the core class used to represent server data in the client application (Collections are
@@ -26,8 +36,6 @@ export default class Model {
26
36
  * * ...any other options that .set() takes
27
37
  */
28
38
  constructor(attributes={}, options={}) {
29
- const RESERVED_OPTION_KEYS = ['parse', 'collection', 'silent', 'unset'];
30
-
31
39
  this.cid = uniqueId('c');
32
40
  this.attributes = {};
33
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resourcerer",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "repository": "github.com/noahgrant/resourcerer",
5
5
  "description": "Declarative data-fetching and caching framework for React",
6
6
  "keywords": [
@@ -50,6 +50,19 @@ describe('Collection', () => {
50
50
  expect(collection.toJSON()).toEqual([]);
51
51
  });
52
52
 
53
+ it('urlOptions get passed down to models', async() => {
54
+ collection = new Collection([{id: '1'}], {one: 1, two: 2, comparator: 'foo', parse: true});
55
+
56
+ expect(collection.get('1').urlOptions).toEqual({one: 1, two: 2});
57
+
58
+ collection.add({id: '2'});
59
+ expect(collection.get('2').urlOptions).toEqual({one: 1, two: 2});
60
+
61
+ sync.default.mockResolvedValue([[{id: '3'}], {}]);
62
+ await collection.fetch();
63
+ expect(collection.get('3').urlOptions).toEqual({one: 1, two: 2});
64
+ });
65
+
53
66
  it('adds any models passed to its models list', () => {
54
67
  var model1 = new Model,
55
68
  model2 = new Model;