Comparing version 4.0.0-beta.2 to 4.0.0-beta.3
@@ -0,1 +1,3 @@ | ||
const isString = require('lodash/isString'); | ||
const createAction = require('../lib/createAction'); | ||
const isNot = require('../lib/isNot'); | ||
@@ -24,4 +26,7 @@ | ||
*/ | ||
dispatch(action) { | ||
isNot(action, 'valid action', 'action'); | ||
dispatch(action, payload) { | ||
isString(action) | ||
? action = createAction(action, payload) | ||
: isNot(action, 'valid action', 'action'); | ||
return this.send(action); | ||
@@ -28,0 +33,0 @@ } |
{ | ||
"name": "redbone", | ||
"version": "4.0.0-beta.2", | ||
"version": "4.0.0-beta.3", | ||
"description": "Polymorphic library for two-way dispatching of actions", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"author": "Constantin T.", | ||
"license": "MIT", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
@@ -25,5 +25,4 @@ "lodash": "^4.17.15" | ||
"eslint-plugin-security": "^1.4.0", | ||
"jest": "^24.9.0", | ||
"socket.io": "^2.3.0" | ||
"jest": "^24.9.0" | ||
} | ||
} |
@@ -140,3 +140,3 @@ # Redbone | ||
class RedboneTransportTCP { | ||
class TransportTCP { | ||
constructor(options) { | ||
@@ -272,4 +272,4 @@ this.redbone = new Redbone(); | ||
RedboneTransportTCP.Types = Types; | ||
module.exports = RedboneTransportTCP; | ||
TransportTCP.Types = Types; | ||
module.exports = TransportTCP; | ||
``` | ||
@@ -276,0 +276,0 @@ |
@@ -13,3 +13,2 @@ /* global test expect describe jest */ | ||
const client = new Client(); | ||
const type = 'test'; | ||
@@ -26,2 +25,27 @@ | ||
test('creates action from type', () => { | ||
const client = new Client(); | ||
const type = 'test'; | ||
const payload = {}; | ||
const onlyType = jest.fn((action) => { | ||
expect(action.type).toBe(type); | ||
expect(action.payload).not.toBeDefined(); | ||
}); | ||
const withPayload = jest.fn((action) => { | ||
expect(action.type).toBe(type); | ||
expect(action.payload).toBe(payload); | ||
}); | ||
client.native = onlyType; | ||
client.dispatch(type); | ||
client.native = withPayload; | ||
client.dispatch(type, payload); | ||
expect(onlyType.mock.calls.length).toBe(1); | ||
expect(withPayload.mock.calls.length).toBe(1); | ||
}); | ||
test('doesn\'t take invalid action', () => { | ||
@@ -31,3 +55,2 @@ const client = new Client(); | ||
expect(() => client.dispatch({})).toThrow(ErrorText.ACTION_INVALID); | ||
expect(() => client.dispatch('test')).toThrow(ErrorText.ACTION_INVALID); | ||
expect(() => client.dispatch()).toThrow(ErrorText.ACTION_INVALID); | ||
@@ -34,0 +57,0 @@ expect(() => client.dispatch(null)).toThrow(ErrorText.ACTION_INVALID); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41659
4
22
661