Skip to content

Commit ba5579b

Browse files
committed
typefix tests
1 parent 5a2c622 commit ba5579b

File tree

4 files changed

+87
-75
lines changed

4 files changed

+87
-75
lines changed

packages/sdk/src/sdk/api/albums/AlbumsApi.test.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,26 @@ vitest.mock('../tracks/TrackUploadHelper')
4242
vitest.mock('../tracks/TrackUploadHelper')
4343
vitest.mock('../generated/default/apis/PlaylistsApi')
4444

45-
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(async () => {
45+
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(() => {
4646
return {
47-
id: 'a',
48-
status: 'done',
49-
results: {
50-
'320': 'a'
51-
},
52-
orig_file_cid:
53-
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
54-
orig_filename: 'file.wav',
55-
probe: {
56-
format: {
57-
duration: '10'
58-
}
59-
},
60-
audio_analysis_error_count: 0,
61-
audio_analysis_results: {}
47+
start: async () => ({
48+
id: 'a',
49+
status: 'done',
50+
results: {
51+
'320': 'a'
52+
},
53+
orig_file_cid:
54+
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
55+
orig_filename: 'file.wav',
56+
probe: {
57+
format: {
58+
duration: '10'
59+
}
60+
},
61+
audio_analysis_error_count: 0,
62+
audio_analysis_results: {}
63+
}),
64+
abort: () => {}
6265
}
6366
})
6467

packages/sdk/src/sdk/api/playlists/PlaylistsApi.test.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,28 @@ vitest.mock('../tracks/TrackUploadHelper')
3030
vitest.mock('../tracks/TrackUploadHelper')
3131
vitest.mock('../generated/default/apis/PlaylistsApi')
3232

33-
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(async () => {
34-
return {
35-
id: 'a',
36-
status: 'done',
37-
results: {
38-
'320': 'a'
39-
},
40-
orig_file_cid:
41-
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
42-
orig_filename: 'file.wav',
43-
probe: {
44-
format: {
45-
duration: '10'
46-
}
47-
},
48-
audio_analysis_error_count: 0,
49-
audio_analysis_results: {}
50-
}
51-
})
33+
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(() => ({
34+
start: async () => {
35+
return {
36+
id: 'a',
37+
status: 'done',
38+
results: {
39+
'320': 'a'
40+
},
41+
orig_file_cid:
42+
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
43+
orig_filename: 'file.wav',
44+
probe: {
45+
format: {
46+
duration: '10'
47+
}
48+
},
49+
audio_analysis_error_count: 0,
50+
audio_analysis_results: {}
51+
}
52+
},
53+
abort: () => {}
54+
}))
5255

5356
vitest
5457
.spyOn(TrackUploadHelper.prototype, 'generateId' as any)

packages/sdk/src/sdk/api/tracks/TracksApi.test.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,28 @@ vitest.mock('../../services/StorageNodeSelector')
3939
vitest.mock('../../services/Storage')
4040
vitest.mock('./TrackUploadHelper')
4141

42-
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(async () => {
43-
return {
44-
id: 'a',
45-
status: 'done',
46-
results: {
47-
'320': 'a'
48-
},
49-
orig_file_cid:
50-
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
51-
orig_filename: 'file.wav',
52-
probe: {
53-
format: {
54-
duration: '10'
55-
}
56-
},
57-
audio_analysis_error_count: 0,
58-
audio_analysis_results: {}
59-
}
60-
})
42+
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(() => ({
43+
start: async () => {
44+
return {
45+
id: 'a',
46+
status: 'done',
47+
results: {
48+
'320': 'a'
49+
},
50+
orig_file_cid:
51+
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
52+
orig_filename: 'file.wav',
53+
probe: {
54+
format: {
55+
duration: '10'
56+
}
57+
},
58+
audio_analysis_error_count: 0,
59+
audio_analysis_results: {}
60+
}
61+
},
62+
abort: () => {}
63+
}))
6164

6265
vitest
6366
.spyOn(TrackUploadHelper.prototype, 'generateId' as any)
@@ -192,7 +195,7 @@ describe('TracksApi', () => {
192195
const result = await tracks.updateTrack({
193196
userId: '7eP5n',
194197
trackId: 'ogRRByg',
195-
coverArtFile: {
198+
imageFile: {
196199
buffer: pngFile,
197200
name: 'coverArt'
198201
},
@@ -214,7 +217,7 @@ describe('TracksApi', () => {
214217
await tracks.updateTrack({
215218
userId: '7eP5n',
216219
trackId: 'ogRRByg',
217-
coverArtFile: {
220+
imageFile: {
218221
buffer: pngFile,
219222
name: 'coverArt'
220223
},

packages/sdk/src/sdk/api/users/UsersApi.test.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,28 @@ const pngFile = fs.readFileSync(
3737

3838
vitest.mock('../../services/EntityManager')
3939

40-
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(async () => {
41-
return {
42-
id: 'a',
43-
status: 'done',
44-
results: {
45-
'320': 'a'
46-
},
47-
orig_file_cid:
48-
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
49-
orig_filename: 'file.wav',
50-
probe: {
51-
format: {
52-
duration: '10'
53-
}
54-
},
55-
audio_analysis_error_count: 0,
56-
audio_analysis_results: {}
57-
}
58-
})
40+
vitest.spyOn(Storage.prototype, 'uploadFile').mockImplementation(() => ({
41+
start: async () => {
42+
return {
43+
id: 'a',
44+
status: 'done',
45+
results: {
46+
'320': 'a'
47+
},
48+
orig_file_cid:
49+
'baeaaaiqsea7fukrfrjrugqts6jqfmqhcb5ruc5pjmdk3anj7amoht4d4gemvq',
50+
orig_filename: 'file.wav',
51+
probe: {
52+
format: {
53+
duration: '10'
54+
}
55+
},
56+
audio_analysis_error_count: 0,
57+
audio_analysis_results: {}
58+
}
59+
},
60+
abort: () => {}
61+
}))
5962

6063
vitest
6164
.spyOn(EntityManagerClient.prototype, 'manageEntity')

0 commit comments

Comments
 (0)