1+ const commtrackr = require ( './index.js' ) ;
2+
3+ async function commTrackrHandler ( data ) {
4+ return data ;
5+ } ;
6+
7+ commtrackr . on ( ) ;
8+
9+ describe ( 'CommTrackr Backend Initialization' , ( ) => {
10+ test ( 'on' , ( ) => {
11+ expect ( typeof commtrackr . on ) . toBe ( 'function' ) ;
12+ expect ( ( ) => commtrackr . on ( ) ) . not . toThrow ( ) ;
13+ } ) ;
14+ test ( 'init' , ( ) => {
15+ expect ( typeof commtrackr . init ) . toBe ( 'function' ) ;
16+ expect ( ( ) => commtrackr . init ( {
17+ tenant : {
18+ slug : 'commtrackr' ,
19+ name : 'CommTrackr' ,
20+ description : 'Testing' ,
21+ logo : 'http://localhost:3000/logo.png' ,
22+ domain : 'http://localhost:3000' ,
23+ path : '/commissions' ,
24+ auth : {
25+ enabled : true ,
26+ provider : 'Test Authentication Provider' ,
27+ url : '/login'
28+ } ,
29+ } ,
30+ vars : {
31+ userId : 'id' ,
32+ name : 'name' ,
33+ access : {
34+ var : 'access' ,
35+ user : [ 0 ] ,
36+ dev : [ 1 ] ,
37+ admin : [ 2 ]
38+ } ,
39+ } ,
40+ fields : [ 'text' , 'number' , 'date' , 'textarea' , 'checkbox' , 'radio' , 'select' ] . flatMap ( fieldType => [
41+ {
42+ id : `test-${ fieldType } ` ,
43+ type : fieldType ,
44+ label : fieldType ,
45+ description : 'description' ,
46+ placeholder : 'placeholder' ,
47+ required : false
48+ } ,
49+ {
50+ id : `test-${ fieldType } -required` ,
51+ type : fieldType ,
52+ label : fieldType ,
53+ description : 'description' ,
54+ placeholder : 'placeholder' ,
55+ required : true
56+ }
57+ ] ) ,
58+ handler : commTrackrHandler ,
59+ } ) ) . not . toThrow ( ) ;
60+ } ) ;
61+ test ( 'handler' , async ( ) => {
62+ expect ( typeof commTrackrHandler ) . toBe ( 'function' ) ;
63+ const result = await commTrackrHandler ( { test : 'data' } ) ;
64+ expect ( typeof result ) . toBe ( 'object' ) ;
65+ expect ( result ) . toHaveProperty ( 'test' , 'data' ) ;
66+ } ) ;
67+ } ) ;
0 commit comments