1
1
import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
2
2
import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
3
3
import { By } from '@angular/platform-browser' ;
4
- import { BehaviorSubject } from 'rxjs' ;
5
4
import { ApiService } from '../../../../../common/api/api.service' ;
6
5
import { CommonModule } from '../../../../../common/common.module' ;
7
6
import { ButtonComponent } from '../../../../../common/components/button/button.component' ;
8
- import { AutocompleteUserInputComponent } from '../../../../../common/components/forms/autocomplete-user-input/autocomplete-user-input.component' ;
9
7
import { ConfigsService } from '../../../../../common/services/configs.service' ;
10
- import { Client } from '../../../../../services/api' ;
11
- import { Session } from '../../../../../services/session' ;
12
8
import { MockComponent , MockService } from '../../../../../utils/mock' ;
13
- import { PaymentsModule } from '../../../../payments/payments.module' ;
14
- import {
15
- ComposerService ,
16
- ComposerSize ,
17
- } from '../../../services/composer.service' ;
9
+ import { ComposerService } from '../../../services/composer.service' ;
18
10
import { PopupService } from '../popup.service' ;
19
11
import { ComposerSupermindComponent } from '../supermind/supermind.component' ;
12
+ import { EntityResolverService } from '../../../../../common/services/entity-resolver.service' ;
13
+ import { of } from 'rxjs' ;
20
14
21
15
describe ( 'Composer Supermind Popup' , ( ) => {
22
16
let comp : ComposerSupermindComponent ;
@@ -49,6 +43,10 @@ describe('Composer Supermind Popup', () => {
49
43
present : { toPromise : ( ) => { } } ,
50
44
} ) ;
51
45
46
+ const apiMock = new ( function ( ) {
47
+ this . get = jasmine . createSpy ( 'get' ) ;
48
+ } ) ( ) ;
49
+
52
50
beforeEach (
53
51
waitForAsync ( ( ) => {
54
52
TestBed . configureTestingModule ( {
@@ -71,7 +69,7 @@ describe('Composer Supermind Popup', () => {
71
69
} ,
72
70
{
73
71
provide : ApiService ,
74
- useValue : MockService ( ApiService ) ,
72
+ useValue : apiMock ,
75
73
} ,
76
74
// {
77
75
// provide: Client,
@@ -84,7 +82,11 @@ describe('Composer Supermind Popup', () => {
84
82
// {
85
83
// provide: Session,
86
84
// useValue: MockService(Session),
87
- // }
85
+ // },
86
+ {
87
+ provide : EntityResolverService ,
88
+ useValue : MockService ( EntityResolverService ) ,
89
+ } ,
88
90
] ,
89
91
} ) . compileComponents ( ) ;
90
92
} )
@@ -93,6 +95,27 @@ describe('Composer Supermind Popup', () => {
93
95
beforeEach ( done => {
94
96
fixture = TestBed . createComponent ( ComposerSupermindComponent ) ;
95
97
comp = fixture . componentInstance ;
98
+
99
+ ( comp as any ) . mindsConfig . get . and . returnValue ( {
100
+ min_thresholds : {
101
+ min_cash : 10 ,
102
+ min_offchain_tokens : 1 ,
103
+ } ,
104
+ } ) ;
105
+
106
+ ( comp as any ) . entityResolverService . get$ . and . returnValue (
107
+ of ( {
108
+ supermind_settings : {
109
+ min_cash : 10 ,
110
+ min_offchain_tokens : 1 ,
111
+ } ,
112
+ merchant : { } ,
113
+ } )
114
+ ) ;
115
+
116
+ apiMock . get . calls . reset ( ) ;
117
+ apiMock . get . and . returnValue ( [ ] ) ;
118
+
96
119
fixture . detectChanges ( ) ;
97
120
98
121
if ( fixture . isStable ( ) ) {
@@ -128,13 +151,13 @@ describe('Composer Supermind Popup', () => {
128
151
comp . formGroup . controls . termsAccepted . setValue ( true ) ;
129
152
comp . formGroup . controls . username . setValue ( 'minds' ) ;
130
153
fixture . detectChanges ( ) ;
131
-
132
154
expect ( getSaveBtn ( ) . disabled ) . toBeFalse ( ) ;
133
155
} ) ;
134
156
135
157
it ( 'should update composer supermindRequest$ service on save' , ( ) => {
136
158
comp . formGroup . controls . termsAccepted . setValue ( true ) ;
137
159
comp . formGroup . controls . username . setValue ( 'minds' ) ;
160
+ // comp.formGroup.controls.username.markAsTouched({ onlySelf: true });
138
161
fixture . detectChanges ( ) ;
139
162
140
163
getSaveBtn ( ) . onAction . next ( new MouseEvent ( 'click' ) ) ;
0 commit comments