Ensure text.wrap property can accept word-char as value (#4028)

This commit is contained in:
Aaron Che
2024-03-17 16:15:03 +08:00
committed by GitHub
parent 88aee8a887
commit 8fbb1cd154
6 changed files with 11 additions and 11 deletions

View File

@@ -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/
);
});
});