1- export function createInputReceivers ( config = { } ) {
1+ export function createInputReceivers ( config = { } ) {
22 let inputs = null ;
33 let input = null ;
44 if ( config . initData && config . initData . form && config . initData . form . fields ) {
5- inputs = config . initData . form . fields . map ( ( field ) => {
6- field . operations = {
7- onInput :( ) => { }
8- } ;
9- return createWaitForInputMessage ( field . operations )
10- }
11- ) ;
5+ inputs = config . initData . form . fields . map ( ( field ) => {
6+ field . operations = {
7+ onInput : ( ) => { }
8+ } ;
9+ return createWaitForInputMessage ( field . operations )
10+ }
11+ ) ;
1212 }
1313 else {
14- input = createWaitForInputMessage ( config ) ;
14+ input = createWaitForInputMessage ( config ) ;
1515 }
1616 return { config, input, inputs } ;
17- }
18-
19- const createPromise = ( target ) => {
17+ }
18+
19+ const createPromise = ( target ) => {
2020 target . promise = new Promise ( ( resolve , reject ) => {
21- target . resolve = resolve ;
22- target . reject = reject ;
21+ target . resolve = resolve ;
22+ target . reject = reject ;
2323 } ) ;
24- } ;
25-
26- function createWaitForInputMessage ( target ) {
27- const input = { } ;
24+ } ;
25+
26+ function createWaitForInputMessage ( target ) {
27+ const input = { } ;
2828
2929 createPromise ( input ) ;
3030 target . onInput = ( message ) => {
31- input . resolve ( message ) ;
32- createPromise ( input ) ;
31+ input . resolve ( message ) ;
32+ createPromise ( input ) ;
3333 } ;
3434 input . get = ( ) => input . promise ;
35-
35+
3636 return input ;
37- } ;
37+ } ;
3838
3939/**
4040 * compare initData to expectedInitData
41- * @param {* } initData
42- * @param {* } expectedInitData
41+ * @param {* } initData
42+ * @param {* } expectedInitData
4343 */
4444
4545
4646export function toBeSameInitData ( received , expected ) {
47+ if ( ! received ) {
48+ return {
49+ pass : false ,
50+ message : ( ) => `action = "${ expected . action } " is expected but received empty content instead`
51+ } ;
52+ }
4753 if ( received . action !== expected . action ) {
4854 return {
4955 pass : false ,
@@ -106,8 +112,3 @@ export function toBeSameInitData(received, expected) {
106112 message : ( ) => `received initData contains the same data as in the expected initData`
107113 } ;
108114}
109-
110-
111-
112-
113-
0 commit comments