Repository: ViacomInc/data-point
Pull request #216 (2018-02-15 20:58:58)

refactor(packages/data-point/lib/reducer-types): Changed reducer cons…
…tructors to be exported as 'Con

#119

<!--
Thanks for your interest in the project. We appreciate bugs filed and PRs submitted!

Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).

Also, please make sure you're familiar with and follow the instructions in the
contributing guidelines (found in the CONTRIBUTING.md file).

Please fill out the information below to expedite the review and (hopefully)
merge of your pull request!

BREAKING CHANGES:

If your PR includes a breaking change, please submit it with a codemod under
data-point-codemods that will help users upgrade their codebase.

Breaking changes without a codemod will not be accepted unless a codemod is not
viable or does not apply to the specific situation.
-->

<!-- What changes are being made? (What feature/bug is being fixed here?) -->
**What**: Reducer type constructor functions all share the name 

> Constructor

 

<!-- Why are these changes necessary? -->
**Why**: So we can have a consistent export name for every reducer type

<!-- How were these changes implemented? -->
**How**: 
Replaced reducer functions constructor export from being its own name 
ex: 
`module.exports.ReducerList = ReducerList`

to

`module.exports.Constructor = ReducerList`


<!-- Have you done all of these things?  -->
**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
- [ ] Has Breaking changes
- [ ] Documentation
- [ ] Tests
- [ ] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
- [ ] Added username to **all-contributors** list

<!-- feel free to add additional comments -->


coveralls: 
[![Coverage Status](https://coveralls.io/builds/15547208/badge)](https://coveralls.io/builds/15547208)

Coverage remained the same at 100.0% when pulling **391c3bcde55df6afb6e9aa73c0dc1ca032b7f363 on victorsingh:export-default-reducers** into **b60824509467af599ef12d730a1b6cf8778d0b9d on ViacomInc:master**.


Patch:
diff --git a/packages/data-point/lib/reducer-types/reducer-function/factory.js b/packages/data-point/lib/reducer-types/reducer-function/factory.js
index b233c01..1e076e3 100644
--- a/packages/data-point/lib/reducer-types/reducer-function/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-function/factory.js
@@ -18,7 +18,7 @@ function ReducerFunction () {
   this.body = undefined
 }
 
-module.exports.ReducerFunction = ReducerFunction
+module.exports.Constructor = ReducerFunction
 
 /**
  * @param {*} source
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.js
index 706e541..e52b98a 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.js
@@ -16,7 +16,7 @@ function ReducerAssign () {
   this.reducer = undefined
 }
 
-module.exports.ReducerAssign = ReducerAssign
+module.exports.Constructor = ReducerAssign
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.js
index 88afdc1..7db7b30 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.js
@@ -16,7 +16,7 @@ function ReducerConstant () {
   this.value = undefined
 }
 
-module.exports.ReducerConstant = ReducerConstant
+module.exports.Constructor = ReducerConstant
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.js
index 42667d6..c03d391 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.js
@@ -16,7 +16,7 @@ function ReducerFilter () {
   this.transform = undefined
 }
 
-module.exports.ReducerFilter = ReducerFilter
+module.exports.Constructor = ReducerFilter
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.js
index fc6db65..4fa4f68 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.js
@@ -16,7 +16,7 @@ function ReducerFind () {
   this.reducer = undefined
 }
 
-module.exports.ReducerFind = ReducerFind
+module.exports.Constructor = ReducerFind
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.js
index ff649b8..72a9661 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.js
@@ -16,7 +16,7 @@ function ReducerMap () {
   this.reducer = undefined
 }
 
-module.exports.ReducerMap = ReducerMap
+module.exports.Constructor = ReducerMap
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.js
index d538915..fd60693 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.js
@@ -16,7 +16,7 @@ function ReducerOmit () {
   this.keys = undefined
 }
 
-module.exports.ReducerOmit = ReducerOmit
+module.exports.Constructor = ReducerOmit
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.js
index ee4c946..d028d89 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.js
@@ -16,7 +16,7 @@ function ReducerParallel () {
   this.reducers = []
 }
 
-module.exports.ReducerParallel = ReducerParallel
+module.exports.Constructor = ReducerParallel
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.js
index 1fa4372..49cebca 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.js
@@ -13,7 +13,7 @@ function ReducerStub (type, args) {
   this.args = args
 }
 
-module.exports.ReducerStub = ReducerStub
+module.exports.Constructor = ReducerStub
 
 /**
  * @param {*} source
diff --git a/packages/data-point/lib/reducer-types/reducer-list/factory.js b/packages/data-point/lib/reducer-types/reducer-list/factory.js
index c9e3e23..fbcd3eb 100644
--- a/packages/data-point/lib/reducer-types/reducer-list/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-list/factory.js
@@ -15,7 +15,7 @@ function ReducerList () {
   this.reducers = []
 }
 
-module.exports.ReducerList = ReducerList
+module.exports.Constructor = ReducerList
 
 /**
  * @param {*} source
diff --git a/packages/data-point/lib/reducer-types/reducer-object/factory.js b/packages/data-point/lib/reducer-types/reducer-object/factory.js
index e8e4e25..3ce738e 100644
--- a/packages/data-point/lib/reducer-types/reducer-object/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-object/factory.js
@@ -17,7 +17,7 @@ function ReducerObject () {
   this.reducers = undefined
 }
 
-module.exports.ReducerObject = ReducerObject
+module.exports.Constructor = ReducerObject
 
 /**
  * @param {*} source
diff --git a/packages/data-point/lib/reducer-types/reducer-path/factory.js b/packages/data-point/lib/reducer-types/reducer-path/factory.js
index 5415734..94b4a80 100644
--- a/packages/data-point/lib/reducer-types/reducer-path/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-path/factory.js
@@ -17,7 +17,7 @@ function ReducerPath () {
   this.asCollection = false
 }
 
-module.exports.ReducerPath = ReducerPath
+module.exports.Constructor = ReducerPath
 
 /**
  * @param {*} source


Test patch:
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.test.js
index 9d3c5ec..051d48d 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-assign/factory.test.js
@@ -6,7 +6,7 @@ const createReducer = require('../../index').create
 describe('ReducerAssign#factory', () => {
   test('It should create a ReducerAssign object', () => {
     const reducer = Factory.create(createReducer, {})
-    expect(reducer).toBeInstanceOf(Factory.ReducerAssign)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.reducer).toHaveProperty('type', 'ReducerObject')
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.test.js
index ede8daa..c34d839 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-constant/factory.test.js
@@ -6,7 +6,7 @@ const createReducer = require('../../index').create
 describe('ReducerConstant#factory', () => {
   test('reducer with undefined as value', () => {
     const reducer = Factory.create(createReducer)
-    expect(reducer).toBeInstanceOf(Factory.ReducerConstant)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.value).toBe(undefined)
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.test.js
index 4b0a4b2..ffa9caf 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-filter/factory.test.js
@@ -6,7 +6,7 @@ const createReducer = require('../../index').create
 describe('ReducerFilter#factory', () => {
   test('It should create a ReducerFilter object', () => {
     const reducer = Factory.create(createReducer, {})
-    expect(reducer).toBeInstanceOf(Factory.ReducerFilter)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.reducer).toHaveProperty('type', 'ReducerObject')
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.test.js
index 2f670d4..6bf3276 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-find/factory.test.js
@@ -6,7 +6,7 @@ const createReducer = require('../../index').create
 describe('ReducerFind#factory', () => {
   test('It should create a ReducerFind object', () => {
     const reducer = Factory.create(createReducer, {})
-    expect(reducer).toBeInstanceOf(Factory.ReducerFind)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.reducer).toHaveProperty('type', 'ReducerObject')
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.test.js
index 6998a9b..fd5befd 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-map/factory.test.js
@@ -6,7 +6,7 @@ const createReducer = require('../../index').create
 describe('ReducerMap#factory', () => {
   test('It should create a ReducerMap object', () => {
     const reducer = Factory.create(createReducer, {})
-    expect(reducer).toBeInstanceOf(Factory.ReducerMap)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.reducer).toHaveProperty('type', 'ReducerObject')
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.test.js
index 99668f3..a80a638 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-omit/factory.test.js
@@ -7,7 +7,7 @@ describe('ReducerOmit#factory', () => {
   test('It should create a ReducerOmit object', () => {
     const args = ['$a', '$b']
     const reducer = Factory.create(createReducer, args)
-    expect(reducer).toBeInstanceOf(Factory.ReducerOmit)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.keys).toEqual(args)
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.test.js
index cbc7105..5cf6cd3 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-parallel/factory.test.js
@@ -7,7 +7,7 @@ describe('ReducerParallel#factory', () => {
   test('It should create a ReducerParallel object', () => {
     const source = ['$a', () => true]
     const reducer = Factory.create(createReducer, source)
-    expect(reducer).toBeInstanceOf(Factory.ReducerParallel)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(reducer.type).toBe(Factory.type)
     expect(reducer.reducers).toMatchSnapshot()
   })
diff --git a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.test.js b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.test.js
index eee50ad..405aa5d 100644
--- a/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-helpers/reducer-stub.test.js
@@ -5,7 +5,7 @@ const Factory = require('./reducer-stub')
 describe('ReducerStub#factory', () => {
   test('It should create a ReducerStub object', () => {
     const reducer = Factory.create('ReducerPick', '$a', '$b')
-    expect(reducer).toBeInstanceOf(Factory.ReducerStub)
+    expect(reducer).toBeInstanceOf(Factory.Constructor)
     expect(Factory.isType(reducer)).toBe(true)
     expect(Factory.isType({ type: 'ReducerStub' })).toBe(false)
     expect(reducer[Factory.REDUCER_STUB_SYMBOL]).toBe(true)
diff --git a/packages/data-point/lib/reducer-types/reducer-list/factory.test.js b/packages/data-point/lib/reducer-types/reducer-list/factory.test.js
index a2b33c1..12e3952 100644
--- a/packages/data-point/lib/reducer-types/reducer-list/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-list/factory.test.js
@@ -8,7 +8,7 @@ describe('factory#create', () => {
   test('factory#create default', () => {
     const result = factory.create(createReducer)
 
-    expect(result).toBeInstanceOf(factory.ReducerList)
+    expect(result).toBeInstanceOf(factory.Constructor)
     expect(result.context).toBeUndefined()
     expect(result.reducers).toHaveLength(0)
   })