|
| 1 | +import {Transformation} from '../../../src'; |
| 2 | +import {Delivery} from "../../../src/actions"; |
| 3 | +import {ChromaSubSampling, ColorSpace, Format, Quality} from "../../../src/qualifiers"; |
| 4 | +import {Progressive} from "../../../src/qualifiers/progressive"; |
| 5 | + |
| 6 | +describe('Delivery.toJson()', () => { |
| 7 | + it('delivery.colorSpace', () => { |
| 8 | + const transformation = new Transformation() |
| 9 | + .addAction(Delivery.colorSpace(ColorSpace.trueColor())); |
| 10 | + expect(transformation.toJson()).toStrictEqual( |
| 11 | + [ |
| 12 | + { |
| 13 | + actionType: 'colorSpace', |
| 14 | + mode: 'srgbTrueColor' |
| 15 | + } |
| 16 | + ] |
| 17 | + ); |
| 18 | + }); |
| 19 | + |
| 20 | + it('delivery.dpr', () => { |
| 21 | + const transformation = new Transformation() |
| 22 | + .addAction(Delivery.dpr('auto')); |
| 23 | + expect(transformation.toJson()).toStrictEqual([ |
| 24 | + { |
| 25 | + actionType: 'dpr', |
| 26 | + type: 'auto' |
| 27 | + } |
| 28 | + ]); |
| 29 | + }); |
| 30 | + |
| 31 | + it('delivery.colorSpaceFromICC', () => { |
| 32 | + const transformation = new Transformation() |
| 33 | + .addAction(Delivery.colorSpaceFromICC('sample')); |
| 34 | + expect(transformation.toJson()).toStrictEqual([ |
| 35 | + { |
| 36 | + actionType: 'colorSpaceFromICC', |
| 37 | + publicId: 'sample' |
| 38 | + } |
| 39 | + ]); |
| 40 | + }); |
| 41 | + |
| 42 | + it('delivery.density', () => { |
| 43 | + const transformation = new Transformation() |
| 44 | + .addAction(Delivery.density(1)); |
| 45 | + expect(transformation.toJson()).toStrictEqual([ |
| 46 | + { |
| 47 | + actionType: 'density', |
| 48 | + density: 1 |
| 49 | + } |
| 50 | + ]); |
| 51 | + }); |
| 52 | + |
| 53 | + it('jpg.progressive.semi()', () => { |
| 54 | + const transformation = new Transformation() |
| 55 | + .addAction(Delivery.format(Format.jpg()).progressive(Progressive.semi())); |
| 56 | + expect(transformation.toJson()).toStrictEqual([ |
| 57 | + { |
| 58 | + progressive: { mode: 'semi' }, |
| 59 | + actionType: 'format', |
| 60 | + formatType: 'jpg' |
| 61 | + } |
| 62 | + ]); |
| 63 | + }); |
| 64 | + |
| 65 | + it('jpg.progressive.semi()', () => { |
| 66 | + const transformation = new Transformation() |
| 67 | + .addAction(Delivery.format(Format.jpg()).progressive('semi')); |
| 68 | + expect(transformation.toJson()).toStrictEqual([ |
| 69 | + { |
| 70 | + progressive: { mode: 'semi' }, |
| 71 | + actionType: 'format', |
| 72 | + formatType: 'jpg' |
| 73 | + } |
| 74 | + ]); |
| 75 | + }); |
| 76 | + |
| 77 | + it('gif.lossy()', () => { |
| 78 | + const transformation = new Transformation() |
| 79 | + .addAction(Delivery.format(Format.gif()).lossy()); |
| 80 | + expect(transformation.toJson()).toStrictEqual([ |
| 81 | + { |
| 82 | + actionType: 'format', |
| 83 | + formatType: 'gif', |
| 84 | + lossy: true |
| 85 | + } |
| 86 | + ]); |
| 87 | + }); |
| 88 | + |
| 89 | + it('quality:80', () => { |
| 90 | + const transformation = new Transformation() |
| 91 | + .addAction(Delivery.quality('80')); |
| 92 | + expect(transformation.toJson()).toStrictEqual([ |
| 93 | + { |
| 94 | + actionType: 'quality', |
| 95 | + level: '80' |
| 96 | + } |
| 97 | + ]); |
| 98 | + }); |
| 99 | + |
| 100 | + it('quality:80.quantization', () => { |
| 101 | + const transformation = new Transformation() |
| 102 | + .addAction(Delivery.quality('80').quantization(10)); |
| 103 | + expect(transformation.toJson()).toStrictEqual([ |
| 104 | + { |
| 105 | + actionType: 'quality', |
| 106 | + level: '80', |
| 107 | + quantization: 10 |
| 108 | + } |
| 109 | + ]); |
| 110 | + }); |
| 111 | + |
| 112 | + it('quality:auto', () => { |
| 113 | + const transformation = new Transformation() |
| 114 | + .addAction(Delivery.quality(Quality.auto())); |
| 115 | + expect(transformation.toJson()).toStrictEqual([ |
| 116 | + { |
| 117 | + actionType: 'quality', |
| 118 | + level: 'auto' |
| 119 | + } |
| 120 | + ]); |
| 121 | + }); |
| 122 | + |
| 123 | + it('chromaSubSampling', () => { |
| 124 | + const transformation = new Transformation() |
| 125 | + .addAction(Delivery.quality('75').chromaSubSampling(ChromaSubSampling.chroma420())); |
| 126 | + expect(transformation.toJson()).toStrictEqual([ |
| 127 | + { |
| 128 | + actionType: 'quality', |
| 129 | + level: '75', |
| 130 | + chromaSubSampling: 'CHROMA_420' |
| 131 | + } |
| 132 | + ]); |
| 133 | + }); |
| 134 | +}); |
0 commit comments