Skip to content

Commit

Permalink
Merge pull request #301 from shakacode/justin808-tweak-missing-store-…
Browse files Browse the repository at this point in the history
…message

Update StoreRegistry.js missing store error.
  • Loading branch information
justin808 committed Mar 2, 2016
2 parents cc889ed + 1b405d0 commit 7317b4a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. Items under
Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.
## [Unreleased]

## [3.0.6] - 2016-03-01
##### Fixed
- Improved errors when registered store is not found. See [#301](https://github.com/shakacode/react_on_rails/pull/301) by [justin808](https://github.com/justin808).

## [3.0.5] - 2016-02-26
##### Fixed
- Fixed error in linters rake file for generator. See [#299](https://github.com/shakacode/react_on_rails/pull/299) by [mpugach](https://github.com/mpugach).
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# NEWS

* 2016-02-28: We added a [Projects page](PROJECTS.md). Please edit the page your project or [email us](mailto:contact@shakacode.com) and we'll add you. We also love stars as it helps us attract new users and contributors. [jbhatab](https://github.com/jbhatab) is leading an effort to ease the onboarding process for newbies with simpler project generators. See [#245](https://github.com/shakacode/react_on_rails/issues/245).
* 3.0.5 shipped on Friday, 2/26/2016. Please see the [Changelog](CHANGELOG.md) for details, and let us know if you see any issues! [Migration steps from 1.x](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#migration-steps-v1-to-v2). [Migration steps from 2.x](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#migration-steps-v2-to-v3).
* [RubyGems](https://rubygems.org/gems/react_on_rails/versions/3.0.0.rc.2), `gem "react_on_rails", "~> 3.0.0-rc.2"`
* [NPM](https://www.npmjs.com/package/react-on-rails), `npm i --save react-on-rails@3.0.0-rc.2`
* 3.0.6 shipped on Tuesday, 2016-03-01. Please see the [Changelog](CHANGELOG.md) for details, and let us know if you see any issues! [Migration steps from 1.x](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#migration-steps-v1-to-v2). [Migration steps from 2.x](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#migration-steps-v2-to-v3).
* [RubyGems](https://rubygems.org/gems/react_on_rails/)
* [NPM](https://www.npmjs.com/package/react-on-rails)
* 3.0.0 Highlights:
1. Support for ensuring JavaScript is current when running tests.
2. Support for multiple React components with one Redux store. So you can have a header React component and different body React components talking to the same Redux store!
Expand Down
6 changes: 3 additions & 3 deletions node_package/src/StoreRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
},

/**
* Used by components to get the store which contains props (hydrated store).
* Used by components to get the hydrated store which contains props.
* @param name
* @returns store with given name
*/
Expand All @@ -32,7 +32,7 @@ export default {
} else {
const storeKeys = Array.from(_stores.keys()).join(', ');
console.log('storeKeys', storeKeys);
throw new Error(`Could not find store with name ${name}.\
throw new Error(`Could not find hydrated store with name '${name}'. \
Hydrated store names include [${storeKeys}].`);
}
},
Expand All @@ -47,7 +47,7 @@ Hydrated store names include [${storeKeys}].`);
return _storeGenerators.get(name);
} else {
const storeKeys = Array.from(_storeGenerators.keys()).join(', ');
throw new Error(`Could not find store registered with name ${name}. \
throw new Error(`Could not find store registered with name '${name}'. \
Registered store names include [ ${storeKeys} ]. Maybe you forgot to register the store?`);
}
},
Expand Down
12 changes: 10 additions & 2 deletions node_package/tests/StoreRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ test('StoreRegistry registers and retrieves generator function stores', (assert)
test('StoreRegistry throws error for retrieving unregistered store', (assert) => {
assert.plan(1);
assert.throws(() => StoreRegistry.getStoreGenerator('foobar'),
/Could not find store registered with name foobar/,
'Expected an exception for calling StoreRegistry.get with an invalid name.'
/Could not find store registered with name 'foobar'\. Registered store names include/,
'Expected an exception for calling StoreRegistry.getStoreGenerator with an invalid name.'
);
});

Expand All @@ -46,3 +46,11 @@ test('StoreRegistry getStore, setStore', (assert) => {
assert.deepEqual(actual, expected, 'StoreRegistry should store and retrieve the store');
});

test('StoreRegistry throws error for retrieving unregistered hydrated store', (assert) => {
assert.plan(1);
assert.throws(() => StoreRegistry.getStore('foobar'),
/Could not find hydrated store with name 'foobar'\. Hydrated store names include/,
'Expected an exception for calling StoreRegistry.getStore with an invalid name.'
);
});

0 comments on commit 7317b4a

Please sign in to comment.