|
| 1 | +import {Transformation} from "../../../src"; |
| 2 | +import {Transcode} from "../../../src/actions/transcode"; |
| 3 | +import {AudioCodec} from "../../../src/qualifiers/audioCodec"; |
| 4 | +import {AudioFrequency} from "../../../src/qualifiers/audioFrequency"; |
| 5 | +import {AnimatedFormat} from "../../../src/qualifiers/animatedFormat"; |
| 6 | + |
| 7 | +describe('Transcode toJson()', () => { |
| 8 | + it('transcode.keyframeInterval number', () => { |
| 9 | + const transformation = new Transformation() |
| 10 | + .addAction(Transcode.keyframeInterval(4)); |
| 11 | + expect(transformation.toJson()).toStrictEqual({ |
| 12 | + actions: [ |
| 13 | + { |
| 14 | + actionType: 'keyframeInterval', |
| 15 | + interval: 4 |
| 16 | + } |
| 17 | + ] |
| 18 | + }); |
| 19 | + }); |
| 20 | + |
| 21 | + it('transcode.fps', () => { |
| 22 | + const transformation = new Transformation() |
| 23 | + .addAction(Transcode.fps(4)); |
| 24 | + expect(transformation.toJson()).toStrictEqual({ |
| 25 | + actions: [ |
| 26 | + { |
| 27 | + actionType: 'fps', |
| 28 | + fps: 4 |
| 29 | + } |
| 30 | + ] |
| 31 | + }); |
| 32 | + }); |
| 33 | + |
| 34 | + it('transcode.fpsRange', () => { |
| 35 | + const transformation = new Transformation() |
| 36 | + .addAction(Transcode.fpsRange(4, 7)); |
| 37 | + expect(transformation.toJson()).toStrictEqual({ |
| 38 | + actions: [ |
| 39 | + { |
| 40 | + actionType: 'fps', |
| 41 | + fps: {from: 4, to: 7} |
| 42 | + } |
| 43 | + ] |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + it('transcode.fpsRange from', () => { |
| 48 | + const transformation = new Transformation() |
| 49 | + .addAction(Transcode.fpsRange(4)); |
| 50 | + expect(transformation.toJson()).toStrictEqual({ |
| 51 | + actions: [ |
| 52 | + { |
| 53 | + actionType: 'fps', |
| 54 | + fps: {from: 4} |
| 55 | + } |
| 56 | + ] |
| 57 | + }); |
| 58 | + }); |
| 59 | + |
| 60 | + it('transcode.bitRate', () => { |
| 61 | + const transformation = new Transformation() |
| 62 | + .addAction(Transcode.bitRate('500k')); |
| 63 | + expect(transformation.toJson()).toStrictEqual({ |
| 64 | + actions: [ |
| 65 | + { |
| 66 | + actionType: 'bitRate', |
| 67 | + bitRate: '500k' |
| 68 | + } |
| 69 | + ] |
| 70 | + }); |
| 71 | + }); |
| 72 | + |
| 73 | + it('transcode.bitRate.constant', () => { |
| 74 | + const transformation = new Transformation() |
| 75 | + .addAction(Transcode.bitRate('500k').constant()); |
| 76 | + expect(transformation.toJson()).toStrictEqual({ |
| 77 | + actions: [ |
| 78 | + { |
| 79 | + actionType: 'bitRate', |
| 80 | + bitRate: '500k', |
| 81 | + constant: true |
| 82 | + } |
| 83 | + ] |
| 84 | + }); |
| 85 | + }); |
| 86 | + |
| 87 | + it('transcode.audioCodec', () => { |
| 88 | + const transformation = new Transformation() |
| 89 | + .addAction(Transcode.audioCodec(AudioCodec.aac())); |
| 90 | + expect(transformation.toJson()).toStrictEqual({ |
| 91 | + actions: [ |
| 92 | + { |
| 93 | + actionType: 'audioCodec', |
| 94 | + audioCodec: 'aac', |
| 95 | + } |
| 96 | + ] |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + it('transcode.audioFrequency', () => { |
| 101 | + const transformation = new Transformation() |
| 102 | + .addAction(Transcode |
| 103 | + .audioFrequency('freq8000')); |
| 104 | + expect(transformation.toJson()).toStrictEqual({ |
| 105 | + actions: [ |
| 106 | + { |
| 107 | + actionType: 'audioFrequency', |
| 108 | + audioFrequencyType: 'freq8000', |
| 109 | + } |
| 110 | + ] |
| 111 | + }); |
| 112 | + }); |
| 113 | + |
| 114 | + it('transcode.streamingProfile', () => { |
| 115 | + const transformation = new Transformation() |
| 116 | + .addAction(Transcode |
| 117 | + .streamingProfile("full_hd")); |
| 118 | + expect(transformation.toJson()).toStrictEqual({ |
| 119 | + actions: [ |
| 120 | + { |
| 121 | + actionType: 'streamingProfile', |
| 122 | + profile: 'fullHd', |
| 123 | + } |
| 124 | + ] |
| 125 | + }); |
| 126 | + }); |
| 127 | + |
| 128 | + it('transcode.animatedFormat', () => { |
| 129 | + const transformation = new Transformation() |
| 130 | + .addAction(Transcode |
| 131 | + .toAnimated('gif').delay(20).sampling('4s')); |
| 132 | + expect(transformation.toJson()).toStrictEqual({ |
| 133 | + actions: [ |
| 134 | + { |
| 135 | + actionType: 'toAnimated', |
| 136 | + animatedFormat: 'gif', |
| 137 | + delay: 20, |
| 138 | + sampling: '4s' |
| 139 | + } |
| 140 | + ] |
| 141 | + }); |
| 142 | + }); |
| 143 | +}); |
0 commit comments