mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure text.wrap property can accept word-char as value (#4028)
This commit is contained in:
@@ -595,7 +595,7 @@ sharp({
|
||||
rgba: true,
|
||||
justify: true,
|
||||
spacing: 10,
|
||||
wrap: 'charWord',
|
||||
wrap: 'word-char',
|
||||
},
|
||||
})
|
||||
.png()
|
||||
|
||||
@@ -319,21 +319,21 @@ describe('Text to image', function () {
|
||||
|
||||
it('valid wrap throws', () => {
|
||||
assert.doesNotThrow(() => sharp({ text: { text: 'text', wrap: 'none' } }));
|
||||
assert.doesNotThrow(() => sharp({ text: { text: 'text', wrap: 'wordChar' } }));
|
||||
assert.doesNotThrow(() => sharp({ text: { text: 'text', wrap: 'word-char' } }));
|
||||
});
|
||||
|
||||
it('invalid wrap throws', () => {
|
||||
assert.throws(
|
||||
() => sharp({ text: { text: 'text', wrap: 1 } }),
|
||||
/Expected one of: word, char, wordChar, none for text\.wrap but received 1 of type number/
|
||||
/Expected one of: word, char, word-char, none for text\.wrap but received 1 of type number/
|
||||
);
|
||||
assert.throws(
|
||||
() => sharp({ text: { text: 'text', wrap: false } }),
|
||||
/Expected one of: word, char, wordChar, none for text\.wrap but received false of type boolean/
|
||||
/Expected one of: word, char, word-char, none for text\.wrap but received false of type boolean/
|
||||
);
|
||||
assert.throws(
|
||||
() => sharp({ text: { text: 'text', wrap: 'invalid' } }),
|
||||
/Expected one of: word, char, wordChar, none for text\.wrap but received invalid of type string/
|
||||
/Expected one of: word, char, word-char, none for text\.wrap but received invalid of type string/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user