|
1 | 1 | import {Transformation} from "../../../src"; |
2 | 2 | import {Effect} from "../../../src/actions/effect"; |
| 3 | +import {halftone4x4Orthogonal} from "../../../src/qualifiers/dither"; |
3 | 4 |
|
4 | 5 |
|
5 | 6 | describe('Effect toJson()', () => { |
@@ -79,4 +80,130 @@ describe('Effect toJson()', () => { |
79 | 80 | } |
80 | 81 | ]); |
81 | 82 | }); |
| 83 | + |
| 84 | + it('effect.colorize', () => { |
| 85 | + const transformation = new Transformation() |
| 86 | + .addAction(Effect.colorize(10).color('red')); |
| 87 | + expect(transformation.toJson()).toStrictEqual( [ |
| 88 | + { |
| 89 | + actionType: 'colorize', |
| 90 | + level: 10, |
| 91 | + color: 'red' |
| 92 | + } |
| 93 | + ]); |
| 94 | + }); |
| 95 | + |
| 96 | + it('effect.oilPaint', () => { |
| 97 | + const transformation = new Transformation() |
| 98 | + .addAction(Effect.oilPaint().strength(8)); |
| 99 | + expect(transformation.toJson()).toStrictEqual( [ |
| 100 | + { |
| 101 | + actionType: 'oilPaint', |
| 102 | + level: 8, |
| 103 | + } |
| 104 | + ]); |
| 105 | + }); |
| 106 | + |
| 107 | + it('effect.cartoonify', () => { |
| 108 | + const transformation = new Transformation() |
| 109 | + .addAction(Effect.cartoonify().lineStrength(70).colorReductionLevel(80)); |
| 110 | + expect(transformation.toJson()).toStrictEqual( [ |
| 111 | + { |
| 112 | + actionType: 'cartoonify', |
| 113 | + colorReductionLevel: 80, |
| 114 | + lineStrength: 70 |
| 115 | + } |
| 116 | + ]); |
| 117 | + }); |
| 118 | + |
| 119 | + it('effect.outline', () => { |
| 120 | + const transformation = new Transformation() |
| 121 | + .addAction(Effect.outline().width(100).color("lightblue")); |
| 122 | + expect(transformation.toJson()).toStrictEqual( [ |
| 123 | + { |
| 124 | + actionType: 'outline', |
| 125 | + width: 100, |
| 126 | + color: 'lightblue' |
| 127 | + } |
| 128 | + ]); |
| 129 | + }); |
| 130 | + |
| 131 | + it('effect.blackwhite', () => { |
| 132 | + const transformation = new Transformation() |
| 133 | + .addAction(Effect.blackwhite().threshold(40)); |
| 134 | + expect(transformation.toJson()).toStrictEqual( [ |
| 135 | + { |
| 136 | + actionType: 'blackwhite', |
| 137 | + level: 40, |
| 138 | + } |
| 139 | + ]); |
| 140 | + }); |
| 141 | + |
| 142 | + it('effect.accelerate', () => { |
| 143 | + const transformation = new Transformation() |
| 144 | + .addAction(Effect.accelerate().rate(5)); |
| 145 | + expect(transformation.toJson()).toStrictEqual( [ |
| 146 | + { |
| 147 | + actionType: 'accelerate', |
| 148 | + level: 5, |
| 149 | + } |
| 150 | + ]); |
| 151 | + }); |
| 152 | + |
| 153 | + it('effect.loop', () => { |
| 154 | + const transformation = new Transformation() |
| 155 | + .addAction(Effect.loop().additionalIterations(5)); |
| 156 | + expect(transformation.toJson()).toStrictEqual( [ |
| 157 | + { |
| 158 | + actionType: 'loop', |
| 159 | + iterations: 5, |
| 160 | + } |
| 161 | + ]); |
| 162 | + }); |
| 163 | + |
| 164 | + it('effect.make_transparent', () => { |
| 165 | + const transformation = new Transformation() |
| 166 | + .addAction(Effect.makeTransparent().tolerance(5).colorToReplace('red')); |
| 167 | + expect(transformation.toJson()).toStrictEqual( [ |
| 168 | + { |
| 169 | + actionType: 'makeTransparent', |
| 170 | + tolerance: 5, |
| 171 | + level: 5, |
| 172 | + color: 'red' |
| 173 | + } |
| 174 | + ]); |
| 175 | + }); |
| 176 | + |
| 177 | + it('effect.noise', () => { |
| 178 | + const transformation = new Transformation() |
| 179 | + .addAction(Effect.noise().level(50)); |
| 180 | + expect(transformation.toJson()).toStrictEqual( [ |
| 181 | + { |
| 182 | + actionType: 'noise', |
| 183 | + level: 50, |
| 184 | + } |
| 185 | + ]); |
| 186 | + }); |
| 187 | + |
| 188 | + it('effect.vignette', () => { |
| 189 | + const transformation = new Transformation() |
| 190 | + .addAction(Effect.vignette().strength(5)); |
| 191 | + expect(transformation.toJson()).toStrictEqual( [ |
| 192 | + { |
| 193 | + actionType: 'vignette', |
| 194 | + level: 5, |
| 195 | + } |
| 196 | + ]); |
| 197 | + }); |
| 198 | + |
| 199 | + it('effect.dither', () => { |
| 200 | + const transformation = new Transformation() |
| 201 | + .addAction(Effect.dither().type(halftone4x4Orthogonal())); |
| 202 | + expect(transformation.toJson()).toStrictEqual( [ |
| 203 | + { |
| 204 | + actionType: 'Dither', |
| 205 | + type: 9, |
| 206 | + } |
| 207 | + ]); |
| 208 | + }); |
82 | 209 | }); |
0 commit comments