@@ -4,15 +4,15 @@ import {
4
4
provideHttpClientTesting ,
5
5
} from '@angular/common/http/testing' ;
6
6
import { TestBed } from '@angular/core/testing' ;
7
- import { WeightMeasurement , WeightService } from './weight.service' ;
8
- import { NotificationService } from '../common-components/notification.service' ;
9
7
import { Subject } from 'rxjs' ;
8
+ import { NotificationService } from '../common-components/notification.service' ;
10
9
import { WithingsService } from '../withings/withings.service' ;
10
+ import { WeightMeasurement , WeightService } from './weight.service' ;
11
11
12
12
function setup ( ) {
13
13
const mockNotificationService : jasmine . SpyObj < NotificationService > =
14
14
jasmine . createSpyObj ( [ 'showNotification' ] ) ;
15
- const syncMeasurements = new Subject < void > ( ) ;
15
+ const syncMeasurements = new Subject < never > ( ) ;
16
16
const mockWithingsService : jasmine . SpyObj < WithingsService > =
17
17
jasmine . createSpyObj ( [ 'syncMeasurements' ] ) ;
18
18
mockWithingsService . syncMeasurements . and . returnValue (
@@ -79,7 +79,7 @@ describe('WeightService', () => {
79
79
service . getWeight ( 7 ) . subscribe ( ( measurements ) => {
80
80
expect ( measurements ) . toEqual ( mockResponse ) ;
81
81
} ) ;
82
- syncMeasurements . next ( ) ;
82
+ syncMeasurements . complete ( ) ;
83
83
httpTestingController
84
84
. expectOne ( '/api/weight?period=7' )
85
85
. flush ( mockResponse ) ;
@@ -106,7 +106,7 @@ describe('WeightService', () => {
106
106
service . getWeight ( 7 ) . subscribe ( ( measurements ) => {
107
107
expect ( measurements ) . toEqual ( mockResponse ) ;
108
108
} ) ;
109
- syncMeasurements . next ( ) ;
109
+ syncMeasurements . complete ( ) ;
110
110
httpTestingController
111
111
. expectOne ( '/api/weight?period=7' )
112
112
. error ( new ProgressEvent ( '' ) ) ;
@@ -122,7 +122,7 @@ describe('WeightService', () => {
122
122
service . getWeight ( 7 ) . subscribe ( ( measurements ) => {
123
123
expect ( measurements ) . toEqual ( mockResponse ) ;
124
124
} ) ;
125
- syncMeasurements . next ( ) ;
125
+ syncMeasurements . complete ( ) ;
126
126
service . getWeight ( 7 ) . subscribe ( ( measurements ) => {
127
127
expect ( measurements ) . toEqual ( mockResponse ) ;
128
128
} ) ;
@@ -140,7 +140,7 @@ describe('WeightService', () => {
140
140
service . getWeight ( 30 ) . subscribe ( ( measurements ) => {
141
141
expect ( measurements ) . toEqual ( mockResponse2 ) ;
142
142
} ) ;
143
- syncMeasurements . next ( ) ;
143
+ syncMeasurements . complete ( ) ;
144
144
service . getWeight ( 10 ) . subscribe ( ( measurements ) => {
145
145
expect ( measurements ) . toEqual ( mockResponse ) ;
146
146
} ) ;
@@ -166,7 +166,7 @@ describe('WeightService', () => {
166
166
service . getTodayWeight ( ) . subscribe ( ( measurement ) => {
167
167
expect ( measurement ) . toEqual ( mockResponse . at ( - 1 ) ) ;
168
168
} ) ;
169
- syncMeasurements . next ( ) ;
169
+ syncMeasurements . complete ( ) ;
170
170
httpTestingController
171
171
. expectOne ( '/api/weight?period=1' )
172
172
. flush ( [ mockResponse . at ( - 1 ) ] ) ;
@@ -178,7 +178,7 @@ describe('WeightService', () => {
178
178
service . getTodayWeight ( ) . subscribe ( ( measurement ) => {
179
179
expect ( measurement ) . toEqual ( mockResponse . at ( - 1 ) ) ;
180
180
} ) ;
181
- syncMeasurements . next ( ) ;
181
+ syncMeasurements . complete ( ) ;
182
182
httpTestingController
183
183
. expectOne ( '/api/weight?period=1' )
184
184
. flush ( mockResponse ) ;
@@ -190,7 +190,7 @@ describe('WeightService', () => {
190
190
service . getTodayWeight ( ) . subscribe ( ( measurement ) => {
191
191
expect ( measurement ) . toBeUndefined ( ) ;
192
192
} ) ;
193
- syncMeasurements . next ( ) ;
193
+ syncMeasurements . complete ( ) ;
194
194
httpTestingController . expectOne ( '/api/weight?period=1' ) . flush ( [ ] ) ;
195
195
httpTestingController . verify ( ) ;
196
196
} ) ;
@@ -213,7 +213,7 @@ describe('WeightService', () => {
213
213
service . getTodayWeight ( ) . subscribe ( ( measurement ) => {
214
214
expect ( measurement ) . toEqual ( mockResponse . at ( - 1 ) ) ;
215
215
} ) ;
216
- syncMeasurements . next ( ) ;
216
+ syncMeasurements . complete ( ) ;
217
217
httpTestingController
218
218
. expectOne ( '/api/weight?period=1' )
219
219
. error ( new ProgressEvent ( '' ) ) ;
@@ -229,7 +229,7 @@ describe('WeightService', () => {
229
229
service . getTodayWeight ( ) . subscribe ( ( measurements ) => {
230
230
expect ( measurements ) . toEqual ( mockResponse . at ( - 1 ) ) ;
231
231
} ) ;
232
- syncMeasurements . next ( ) ;
232
+ syncMeasurements . complete ( ) ;
233
233
service . getTodayWeight ( ) . subscribe ( ( measurements ) => {
234
234
expect ( measurements ) . toEqual ( mockResponse . at ( - 1 ) ) ;
235
235
} ) ;
@@ -248,7 +248,7 @@ describe('WeightService', () => {
248
248
expect ( diff ?. fatMassWeight ?. toFixed ( 3 ) ) . toBe ( '-0.056' ) ;
249
249
expect ( diff ?. fatRatio ?. toFixed ( 3 ) ) . toBe ( '-0.033' ) ;
250
250
} ) ;
251
- syncMeasurements . next ( ) ;
251
+ syncMeasurements . complete ( ) ;
252
252
httpTestingController . expectOne ( '/api/weight?period=7' ) . flush ( [
253
253
{
254
254
date : daysBefore ( 3 ) ,
@@ -271,7 +271,7 @@ describe('WeightService', () => {
271
271
service . getDiff ( 7 ) . subscribe ( ( diff ) => {
272
272
expect ( diff ?. weight . toFixed ( 3 ) ) . toBe ( '-0.017' ) ;
273
273
} ) ;
274
- syncMeasurements . next ( ) ;
274
+ syncMeasurements . complete ( ) ;
275
275
httpTestingController . expectOne ( '/api/weight?period=7' ) . flush ( [
276
276
{
277
277
date : daysBefore ( 3 ) ,
@@ -290,7 +290,7 @@ describe('WeightService', () => {
290
290
service . getDiff ( 7 ) . subscribe ( ( diff ) => {
291
291
expect ( diff ) . toBeUndefined ( ) ;
292
292
} ) ;
293
- syncMeasurements . next ( ) ;
293
+ syncMeasurements . complete ( ) ;
294
294
httpTestingController . expectOne ( '/api/weight?period=7' ) . flush ( [
295
295
{
296
296
date : daysBefore ( 3 ) ,
@@ -305,7 +305,7 @@ describe('WeightService', () => {
305
305
service . getDiff ( 7 ) . subscribe ( ( diff ) => {
306
306
expect ( diff ) . toBeUndefined ( ) ;
307
307
} ) ;
308
- syncMeasurements . next ( ) ;
308
+ syncMeasurements . complete ( ) ;
309
309
httpTestingController . expectOne ( '/api/weight?period=7' ) . flush ( [ ] ) ;
310
310
httpTestingController . verify ( ) ;
311
311
} ) ;
@@ -326,7 +326,7 @@ describe('WeightService', () => {
326
326
syncMeasurements,
327
327
} = setup ( ) ;
328
328
service . getDiff ( 7 ) . subscribe ( ) ;
329
- syncMeasurements . next ( ) ;
329
+ syncMeasurements . complete ( ) ;
330
330
httpTestingController
331
331
. expectOne ( '/api/weight?period=7' )
332
332
. error ( new ProgressEvent ( '' ) ) ;
@@ -342,7 +342,7 @@ describe('WeightService', () => {
342
342
service . getDiff ( 7 ) . subscribe ( ( diff ) => {
343
343
expect ( diff ?. weight . toFixed ( 3 ) ) . toEqual ( '-0.010' ) ;
344
344
} ) ;
345
- syncMeasurements . next ( ) ;
345
+ syncMeasurements . complete ( ) ;
346
346
service . getDiff ( 7 ) . subscribe ( ( diff ) => {
347
347
expect ( diff ?. weight . toFixed ( 3 ) ) . toEqual ( '-0.010' ) ;
348
348
} ) ;
@@ -358,7 +358,7 @@ describe('WeightService', () => {
358
358
service . getWeight ( 1 ) . subscribe ( ) ;
359
359
service . getTodayWeight ( ) . subscribe ( ) ;
360
360
service . getDiff ( 1 ) . subscribe ( ) ;
361
- syncMeasurements . next ( ) ;
361
+ syncMeasurements . complete ( ) ;
362
362
const request = httpTestingController . expectOne ( '/api/weight?period=1' ) ;
363
363
request . flush ( mockResponse ) ;
364
364
expect ( request . request . method ) . toBe ( 'GET' ) ;
0 commit comments