aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/helpers')
-rw-r--r--server/tests/helpers/core-utils.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/tests/helpers/core-utils.ts b/server/tests/helpers/core-utils.ts
index d5cac51a3..a6bf5b4c5 100644
--- a/server/tests/helpers/core-utils.ts
+++ b/server/tests/helpers/core-utils.ts
@@ -4,6 +4,8 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { snakeCase } from 'lodash' 5import { snakeCase } from 'lodash'
6import validator from 'validator' 6import validator from 'validator'
7import { getAverageBitrate, getMaxBitrate } from '@shared/core-utils'
8import { VideoResolution } from '@shared/models'
7import { objectConverter, parseBytes } from '../../helpers/core-utils' 9import { objectConverter, parseBytes } from '../../helpers/core-utils'
8 10
9const expect = chai.expect 11const expect = chai.expect
@@ -46,6 +48,9 @@ describe('Parse Bytes', function () {
46 it('Should be invalid when given invalid value', async function () { 48 it('Should be invalid when given invalid value', async function () {
47 expect(parseBytes('6GB 1GB')).to.be.eq(6) 49 expect(parseBytes('6GB 1GB')).to.be.eq(6)
48 }) 50 })
51})
52
53describe('Object', function () {
49 54
50 it('Should convert an object', async function () { 55 it('Should convert an object', async function () {
51 function keyConverter (k: string) { 56 function keyConverter (k: string) {
@@ -94,3 +99,36 @@ describe('Parse Bytes', function () {
94 expect(obj['my_super_key']).to.be.undefined 99 expect(obj['my_super_key']).to.be.undefined
95 }) 100 })
96}) 101})
102
103describe('Bitrate', function () {
104
105 it('Should get appropriate max bitrate', function () {
106 const tests = [
107 { resolution: VideoResolution.H_240P, ratio: 16 / 9, fps: 24, min: 600, max: 800 },
108 { resolution: VideoResolution.H_360P, ratio: 16 / 9, fps: 24, min: 1200, max: 1600 },
109 { resolution: VideoResolution.H_480P, ratio: 16 / 9, fps: 24, min: 2000, max: 2300 },
110 { resolution: VideoResolution.H_720P, ratio: 16 / 9, fps: 24, min: 4000, max: 4400 },
111 { resolution: VideoResolution.H_1080P, ratio: 16 / 9, fps: 24, min: 8000, max: 10000 },
112 { resolution: VideoResolution.H_4K, ratio: 16 / 9, fps: 24, min: 25000, max: 30000 }
113 ]
114
115 for (const test of tests) {
116 expect(getMaxBitrate(test)).to.be.above(test.min * 1000).and.below(test.max * 1000)
117 }
118 })
119
120 it('Should get appropriate average bitrate', function () {
121 const tests = [
122 { resolution: VideoResolution.H_240P, ratio: 16 / 9, fps: 24, min: 350, max: 450 },
123 { resolution: VideoResolution.H_360P, ratio: 16 / 9, fps: 24, min: 700, max: 900 },
124 { resolution: VideoResolution.H_480P, ratio: 16 / 9, fps: 24, min: 1100, max: 1300 },
125 { resolution: VideoResolution.H_720P, ratio: 16 / 9, fps: 24, min: 2300, max: 2500 },
126 { resolution: VideoResolution.H_1080P, ratio: 16 / 9, fps: 24, min: 4700, max: 5000 },
127 { resolution: VideoResolution.H_4K, ratio: 16 / 9, fps: 24, min: 15000, max: 17000 }
128 ]
129
130 for (const test of tests) {
131 expect(getAverageBitrate(test)).to.be.above(test.min * 1000).and.below(test.max * 1000)
132 }
133 })
134})