diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-03-31 07:41:02 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-03-31 07:41:02 -0500 |
| commit | 0ec6a8228c0723710c84cc3c63d4ae627f34cdd2 (patch) | |
| tree | 81c02a8eb766b807edca4256da0c66f8a4db7fb4 /src | |
| parent | 373f63258eb6ffbd4868efda36d21f3c064023ec (diff) | |
| download | slskd-0ec6a8228c0723710c84cc3c63d4ae627f34cdd2.tar.gz | |
fix tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/lib/search.test.js | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/src/web/src/lib/search.test.js b/src/web/src/lib/search.test.js index 85e1d5f6..68afe91c 100644 --- a/src/web/src/lib/search.test.js +++ b/src/web/src/lib/search.test.js @@ -1,34 +1,11 @@ import * as search from './search'; -describe('isConstantBitRate', () => { - it('returns true given a valid MPEG-3 bitrate', () => { - const bitrates = [8,16,24,32,40,48,56,64,80,96,112,128,144,160,192,224,256,320]; - - bitrates.forEach(br => { - expect(search.isConstantBitRate(br)).toBe(true); - }); - }); - - it('returns false given an invalid MPEG-3 bitrate', () => { - const bitrates = [5,7,65,150,321]; - - bitrates.forEach(br => { - expect(search.isConstantBitRate(br)).toBe(false); - }); - }); - - it('returns false given null or undefined', () => { - expect(search.isConstantBitRate(null)).toBe(false); - expect(search.isConstantBitRate()).toBe(false); - }); -}); - describe('filterResponse', () => { it('removes VBR files if "iscbr" is specified', () => { const response = { files: [ - { bitRate: 123 }, - { bitRate: 320 } + { bitRate: 123, isVariableBitRate: true }, + { bitRate: 320, isVariableBitRate: false } ] }; @@ -36,7 +13,7 @@ describe('filterResponse', () => { expect(search.filterResponse({ response, filters })).toMatchObject({ files: [ - { bitRate: 320 } + { bitRate: 320, isVariableBitRate: false } ] }); }); @@ -44,8 +21,8 @@ describe('filterResponse', () => { it('removes CBR files if "isvbr" is specified', () => { const response = { files: [ - { bitRate: 123 }, - { bitRate: 320 } + { bitRate: 123, isVariableBitRate: true }, + { bitRate: 320, isVariableBitRate: false } ] }; @@ -53,7 +30,7 @@ describe('filterResponse', () => { expect(search.filterResponse({ response, filters })).toMatchObject({ files: [ - { bitRate: 123 } + { bitRate: 123, isVariableBitRate: true } ] }); }); @@ -61,8 +38,8 @@ describe('filterResponse', () => { it('removes all files if "iscbr" and "isvbr" are both specified', () => { const response = { files: [ - { bitRate: 123 }, - { bitRate: 320 } + { isVariableBitrate: true }, + { isVariableBitrate: false } ] }; @@ -73,6 +50,40 @@ describe('filterResponse', () => { }); }); + it('removes lossy files if "islossless" is specified', () => { + const response = { + files: [ + { sampleRate: 41000, bitDepth: 16 }, + { bitRate: 320, isVariableBitRate: false } + ] + }; + + const filters = { isLossless: true }; + + expect(search.filterResponse({ response, filters })).toMatchObject({ + files: [ + { sampleRate: 41000, bitDepth: 16 } + ] + }); + }); + + it('removes lossless files if "islossy" is specified', () => { + const response = { + files: [ + { sampleRate: 41000, bitDepth: 16 }, + { bitRate: 320, isVariableBitRate: false } + ] + }; + + const filters = { isLossy: true }; + + expect(search.filterResponse({ response, filters })).toMatchObject({ + files: [ + { bitRate: 320, isVariableBitRate: false } + ] + }); + }); + it('removes files with bitRate less than minBitRate', () => { const response = { files: [ |
