File tree 4 files changed +46
-3
lines changed
4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -139,3 +139,4 @@ public/
139
139
140
140
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
141
141
142
+ testfiles
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " redis-task-queue" ,
3
- "version" : " 1. 0.0" ,
4
- "description" : " " ,
3
+ "version" : " 0.0.1 " ,
4
+ "description" : " Simplest possible implementation to put, pop and bury jobs with Redis as backend. " ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "test" : " echo \" Error: no test specified \" && exit 1 "
7
+ "test" : " jest --watch "
8
8
},
9
9
"keywords" : [],
10
10
"author" : " " ,
Original file line number Diff line number Diff line change
1
+ const utils = require ( "../../src/helpers/utils" ) ;
2
+
3
+ describe ( "utils" , ( ) => {
4
+ let jsonData ;
5
+ let stringData ;
6
+
7
+ beforeEach ( ( ) => {
8
+ jsonData = { name : "hej" , mock : true } ;
9
+ stringData = JSON . stringify ( { name : "hej" , mock : true } ) ;
10
+ } ) ;
11
+ describe ( "storeData" , ( ) => {
12
+ it ( "should return stringified data if received json" , ( ) => {
13
+ expect ( typeof utils . storeObject ( jsonData ) === "string" ) . toBeTruthy ( ) ;
14
+ } ) ;
15
+ it ( "should return stringied data if received string" , ( ) => {
16
+
17
+ expect ( typeof stringData === "string" ) . toBeTruthy ( ) ;
18
+ } ) ;
19
+ it ( "should append id if not existing in the object" , ( ) => {
20
+ expect ( jsonData . id ) . not . toBeDefined ( ) ;
21
+ expect ( JSON . parse ( stringData ) . id ) . not . toBeDefined ( ) ;
22
+ const jsonBase = utils . storeObject ( jsonData ) ;
23
+ expect ( JSON . parse ( jsonBase ) . id ) . toBeDefined ( ) ;
24
+ const stringBase = utils . storeObject ( stringData ) ;
25
+ expect ( JSON . parse ( stringBase ) . id ) . toBeDefined ( ) ;
26
+ } ) ;
27
+ it ( "should not touch the id if already exists" , ( ) => {
28
+ const dataContainingId = jsonData ;
29
+ dataContainingId . id = "123" ;
30
+ const storeData = utils . storeObject ( dataContainingId ) ;
31
+ expect ( JSON . parse ( storeData ) . id ) . toEqual ( dataContainingId . id ) ;
32
+ } ) ;
33
+ } ) ;
34
+ } ) ;
Original file line number Diff line number Diff line change
1
+ const RedisTaskQueue = require ( "../index" ) ;
2
+
3
+ describe ( "index" , ( ) => {
4
+ const instance = new RedisTaskQueue ( ) ;
5
+ it ( "should be instance of a class" , ( ) => {
6
+ expect ( instance ) . toBeInstanceOf ( RedisTaskQueue ) ;
7
+ } ) ;
8
+ } ) ;
You can’t perform that action at this time.
0 commit comments