mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Merge pull request #1134 from rokkie/bugfix/pass-encoding-param
Pass 'encoding' param of VFS' readFileSync to 'toString'
This commit is contained in:
commit
3f36801b29
@ -16,7 +16,7 @@ class VirtualFileSystem {
|
||||
|
||||
if (encoding) {
|
||||
// return a string
|
||||
return typeof data === 'string' ? data : data.toString();
|
||||
return typeof data === 'string' ? data : data.toString(encoding);
|
||||
}
|
||||
|
||||
return new Buffer(data, typeof data === 'string' ? 'base64' : undefined);
|
||||
|
||||
@ -13,6 +13,17 @@ describe('virtual-fs', function() {
|
||||
fs.fileData = {};
|
||||
});
|
||||
|
||||
test('readFileSync', function () {
|
||||
checkMissingFiles(['encoded', 'raw', 'binary']);
|
||||
|
||||
fs.bindFileData({
|
||||
'files/binary': Buffer.from('Buffer content'),
|
||||
});
|
||||
|
||||
const base64Data = fs.readFileSync('files/binary', 'base64');
|
||||
expect(base64Data).toEqual('QnVmZmVyIGNvbnRlbnQ=');
|
||||
});
|
||||
|
||||
test('writeFileSync', function() {
|
||||
checkMissingFiles(['encoded', 'raw', 'binary']);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user