Skip to content

Commit

Permalink
Package refactoring
Browse files Browse the repository at this point in the history
- Removed `underscore`
- Replaced `practicalmeteor:mocha` with `meteortesting:mocha`
- Switched to npm based `sinon` and `chai` packages
- Slight refactoring based on linting
- Test cleanup
  • Loading branch information
hwillson committed Nov 23, 2017
1 parent ee8ef6a commit 376eff1
Show file tree
Hide file tree
Showing 7 changed files with 2,524 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.meteor/local
.meteor/meteorite
node_modules
.npm
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ See this packages [tests](https://github.com/hwillson/meteor-stub-collections/bl

This project was originally created by MDG, and shipped with the [Meteor Guide's](http://guide.meteor.com) [todos](https://github.com/meteor/todos) reference application (thanks MDG!). If you have any questions/comments, open an issue [here](https://github.com/hwillson/meteor-stub-collections/issues).

### 1.0.4 (2017-11-22)

- Allow single collections with `add` ([PR #18](https://github.com/hwillson/meteor-stub-collections/pull/18) - thanks [@Floriferous](https://github.com/Floriferous)!).
- Removed `underscore`
- Replaced `practicalmeteor:mocha` with `meteortesting:mocha`
- Switched to npm based `sinon` and `chai` packages
- Slight refactoring based on linting
- Test cleanup

### 1.0.3

- Fixes [issue #11](https://github.com/hwillson/meteor-stub-collections/issues/11) where some inherited Collection properties were not properly stubbed (thanks [@Davidyuk](https://github.com/Davidyuk)!).
Expand Down
18 changes: 6 additions & 12 deletions stub_collections.js → index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { _ } from 'meteor/underscore';
import { Mongo } from 'meteor/mongo';
import { sinon } from 'meteor/practicalmeteor:sinon';
import sinon from 'sinon';

const StubCollections = (() => {
const publicApi = {};
Expand Down Expand Up @@ -39,19 +38,14 @@ const StubCollections = (() => {
privateApi.sandbox = sinon.sandbox.create();
privateApi.pairs = {};
privateApi.collections = [];
privateApi.symbols = [];
for (let symbol in Mongo.Collection.prototype) {
privateApi.symbols.push(symbol);
}
privateApi.symbols = Object.keys(Mongo.Collection.prototype);

privateApi.stubPair = (pair) => {
privateApi.symbols.forEach((symbol) => {
if (_.isFunction(pair.localCollection[symbol])
&& symbol != 'simpleSchema') {
privateApi.sandbox.stub(
pair.collection,
symbol,
_.bind(pair.localCollection[symbol], pair.localCollection)
if (typeof pair.localCollection[symbol] === 'function'
&& symbol !== 'simpleSchema') {
privateApi.sandbox.stub(pair.collection, symbol).callsFake(
pair.localCollection[symbol].bind(pair.localCollection),
);
}
});
Expand Down

0 comments on commit 376eff1

Please sign in to comment.