You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"\\"tracedSVG.turnPolicy\\" must be one of [TURNPOLICY_BLACK, TURNPOLICY_WHITE, TURNPOLICY_LEFT, TURNPOLICY_RIGHT, TURNPOLICY_MINORITY, TURNPOLICY_MAJORITY, black, white, left, right, minority, majority]",
225
+
]
226
+
`)
227
+
})
228
+
})
229
+
230
+
describe(`threshold`,()=>{
231
+
// valid settings
232
+
it.each([
233
+
[
234
+
`THRESHOLD_AUTO`,
235
+
{
236
+
value: Potrace.THRESHOLD_AUTO,
237
+
expectedIsValid: true,
238
+
},
239
+
],
240
+
[
241
+
0,
242
+
{
243
+
expectedIsValid: true,
244
+
},
245
+
],
246
+
[
247
+
128,
248
+
{
249
+
expectedIsValid: true,
250
+
},
251
+
],
252
+
[
253
+
255,
254
+
{
255
+
expectedIsValid: true,
256
+
},
257
+
],
258
+
])(`Allow setting %s`,async(titleAndMaybeValue,{ value })=>{
259
+
if(typeofvalue===`undefined`){
260
+
// if value wasn't explicitly set use title
261
+
value=titleAndMaybeValue
262
+
}
263
+
264
+
const{ isValid }=awaittestPluginOptionsSchema(
265
+
pluginOptionsSchema,
266
+
{
267
+
tracedSVG: {threshold: value},
268
+
}
269
+
)
270
+
271
+
expect(isValid).toBe(true)
272
+
})
273
+
274
+
// invalid settings
275
+
it.each([
276
+
[
277
+
-5,
278
+
{
279
+
expectedIsValid: false,
280
+
errorMessage: `"tracedSVG.threshold" must be greater than or equal to 0`,
281
+
},
282
+
],
283
+
[
284
+
256,
285
+
{
286
+
expectedIsValid: false,
287
+
errorMessage: `"tracedSVG.threshold" must be less than or equal to 255`,
`Additionally generate WebP versions alongside your chosen file format. They are added as a srcset with the appropriate mimetype and will be loaded in browsers that support the format. Pass true for default support, or an object of options to specifically override those for the WebP files. For example, pass { quality: 80 } to have the WebP images be at quality level 80.`
54
56
),
55
-
tracedSVG: Joi.boolean()
57
+
tracedSVG: Joi.alternatives()
58
+
.try(
59
+
Joi.boolean(),
60
+
Joi.object({
61
+
turnPolicy: Joi.string()
62
+
.valid(
63
+
// this plugin also allow to use key names and not exact values
64
+
`TURNPOLICY_BLACK`,
65
+
`TURNPOLICY_WHITE`,
66
+
`TURNPOLICY_LEFT`,
67
+
`TURNPOLICY_RIGHT`,
68
+
`TURNPOLICY_MINORITY`,
69
+
`TURNPOLICY_MAJORITY`,
70
+
// it also allow using actual policy values
71
+
Potrace.TURNPOLICY_BLACK,
72
+
Potrace.TURNPOLICY_WHITE,
73
+
Potrace.TURNPOLICY_LEFT,
74
+
Potrace.TURNPOLICY_RIGHT,
75
+
Potrace.TURNPOLICY_MINORITY,
76
+
Potrace.TURNPOLICY_MAJORITY
77
+
)
78
+
.default(Potrace.TURNPOLICY_MAJORITY),
79
+
turdSize: Joi.number().default(100),
80
+
alphaMax: Joi.number(),
81
+
optCurve: Joi.boolean().default(true),
82
+
optTolerance: Joi.number().default(0.4),
83
+
threshold: Joi.alternatives()
84
+
.try(
85
+
Joi.number().min(0).max(255),
86
+
Joi.number().valid(Potrace.THRESHOLD_AUTO)
87
+
)
88
+
.default(Potrace.THRESHOLD_AUTO),
89
+
blackOnWhite: Joi.boolean().default(true),
90
+
color: Joi.string().default(`lightgray`),
91
+
background: Joi.string().default(`transparent`),
92
+
})
93
+
)
56
94
.default(false)
57
95
.description(
58
96
`Use traced SVGs for placeholder images instead of the “blur up” effect. Pass true for traced SVGs with the default settings (seen here), or an object of options to override the default. For example, pass { color: "#F00", turnPolicy: "TURNPOLICY_MAJORITY" } to change the color of the trace to red and the turn policy to TURNPOLICY_MAJORITY. See node-potrace parameter documentation for a full listing and explanation of the available options.`
0 commit comments