-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Ruben-Arushanyan/14-v4.2.0
14 v4.2.0
- Loading branch information
Showing
14 changed files
with
258 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const {SecureEventEmitter} = require('../../../.packed') | ||
|
||
test('SecureEventEmitter - exceptions [constructor]', () => { | ||
expect(() => new SecureEventEmitter()).toThrow(/SecureEventEmitter eventTypes must be an array/) | ||
expect(() => new SecureEventEmitter([])).toThrow(/SecureEventEmitter eventTypes must be a not empty array/) | ||
|
||
expect(() => new SecureEventEmitter([4])).toThrow(/eventType must be a string/) | ||
expect(() => new SecureEventEmitter([true])).toThrow(/eventType must be a string/) | ||
expect(() => new SecureEventEmitter([{a: "hello"}])).toThrow(/eventType must be a string/) | ||
|
||
|
||
expect(() => new SecureEventEmitter( | ||
["ab-ab", "ab"], | ||
{}, | ||
)).toThrow(/SecureEventEmitter emitterKey must be a Symbol or String type/) | ||
expect(() => new SecureEventEmitter( | ||
["ab-ab", "ab"], | ||
45 | ||
)).toThrow(/SecureEventEmitter emitterKey must be a Symbol or String type/) | ||
|
||
expect(() => new SecureEventEmitter( | ||
["ab-ab", "ab"], | ||
Symbol("fdfd fdfd fdf"), | ||
45 | ||
)).toThrow(/SecureEventEmitter validatorFunction must be a function/) | ||
|
||
expect(new SecureEventEmitter( | ||
["ab-ab", "ab"], | ||
Symbol("fdfd fdfd fdf"), | ||
)) | ||
|
||
expect(() => new SecureEventEmitter( | ||
["ab-ab", "ab"], | ||
Symbol("fdfd fdfd fdf"), | ||
{} | ||
)).toThrow(/SecureEventEmitter validatorFunction must be a function/) | ||
|
||
expect(new SecureEventEmitter( | ||
["ab-ab", "ab"], | ||
Symbol("fdfd fdfd fdf"), | ||
() => {} | ||
)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const {SecureEventEmitter} = require('../../../.packed') | ||
|
||
test('SecureEventEmitter - exceptions - [emit]', () => { | ||
const emitterKey = Symbol('my emitter key') | ||
const emitter = new SecureEventEmitter( | ||
[ | ||
'xxx', | ||
'yyy', | ||
'zzz' | ||
], | ||
emitterKey | ||
) | ||
|
||
const x = emitter.unlock(emitterKey) | ||
|
||
expect(() => x.emit()).toThrow(/eventType must be a string/) | ||
expect(() => x.emit(45)).toThrow(/eventType must be a string/) | ||
expect(() => x.emit({})).toThrow(/eventType must be a string/) | ||
|
||
|
||
expect(() => x.emit('yy')).toThrow(/not exist/) | ||
expect(x.emit('yyy')) | ||
expect(x.emit('yyy', 45)) | ||
expect(x.emit('yyy', {}, {})) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const {SecureEventEmitter} = require('../../../.packed') | ||
|
||
test('SecureEventEmitter - exceptions - [off]', () => { | ||
const emitter = new SecureEventEmitter( | ||
[ | ||
'xxx', | ||
'yyy', | ||
'zzz' | ||
], | ||
'my emitter key' | ||
) | ||
|
||
|
||
expect(() => emitter.off()).toThrow(/eventType must be a string/) | ||
expect(() => emitter.off(45)).toThrow(/eventType must be a string/) | ||
expect(() => emitter.off({})).toThrow(/eventType must be a string/) | ||
|
||
expect(() => emitter.off("aa")).toThrow(/not exist/) | ||
|
||
expect(() => emitter.off("zzz")).toThrow(/listener must be a function/) | ||
expect(() => emitter.off("zzz", {})).toThrow(/listener must be a function/) | ||
expect(() => emitter.off("zzz", true)).toThrow(/listener must be a function/) | ||
expect(emitter.off("zzz", () => {})) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const {SecureEventEmitter} = require('../../../.packed') | ||
|
||
test('SecureEventEmitter - exceptions - [on]', () => { | ||
const emitter = new SecureEventEmitter( | ||
[ | ||
'xxx', | ||
'yyy', | ||
'zzz' | ||
], | ||
'my emitter key' | ||
) | ||
|
||
expect(() => emitter.on()).toThrow(/eventType must be a string/) | ||
expect(() => emitter.on(45)).toThrow(/eventType must be a string/) | ||
expect(() => emitter.on({})).toThrow(/eventType must be a string/) | ||
|
||
expect(() => emitter.on("aa")).toThrow(/not exist/) | ||
|
||
expect(() => emitter.on("zzz")).toThrow(/listener must be a function/) | ||
expect(() => emitter.on("zzz", {})).toThrow(/listener must be a function/) | ||
expect(() => emitter.on("zzz", true)).toThrow(/listener must be a function/) | ||
expect(emitter.on("zzz", () => {})) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const {SecureEventEmitter} = require('../../../.packed') | ||
|
||
test('SecureEventEmitter - exceptions - [unlock]', () => { | ||
const emitterKey = Symbol('my emitter key') | ||
const emitter = new SecureEventEmitter( | ||
[ | ||
'xxx', | ||
'yyy', | ||
'zzz' | ||
], | ||
emitterKey | ||
) | ||
|
||
|
||
expect(() => emitter.unlock()).toThrow(/Unlock Failed/) | ||
expect(() => emitter.unlock(Symbol())).toThrow(/Unlock Failed/) | ||
expect(() => emitter.unlock(Symbol('my emitter key'))).toThrow(/Unlock Failed/) | ||
expect(() => emitter.unlock(44)).toThrow(/Unlock Failed/) | ||
|
||
expect(emitter.unlock(emitterKey)) | ||
}) |
Oops, something went wrong.