Skip to content

Commit

Permalink
fix(ios): updated Ti.Blob.toString() behaviour to original (#11421)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27350
  • Loading branch information
vijaysingh-axway authored and sgtcoolguy committed Jan 9, 2020
1 parent 4b8b22a commit cbb82a6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/Resources/ti.internal/extensions/ti/ti.blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'ipad') {
const buffer = Ti.createBuffer({ value: '' });
const blob = buffer.toBlob();
blob.constructor.prototype.toString = function () {
return this.text;
const value = this.text;
return (value === undefined) ? '[object TiBlob]' : value;
};
}
30 changes: 30 additions & 0 deletions tests/Resources/ti.blob.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');

describe('Titanium.Blob', function () {
describe('#toString()', function () {
it('binary content', function () {
const blob = Ti.Filesystem.getFile('SmallLogo.png').read();
should(blob.toString()).eql('[object TiBlob]');
});

it('empty string', function () {
const blob = Ti.createBuffer({ value: '' }).toBlob();
should(blob.toString()).eql('');
});

it('text content', function () {
const blob = Ti.createBuffer({ value: 'test toString()' }).toBlob();
should(blob.toString()).eql('test toString()');
});

});
});

0 comments on commit cbb82a6

Please sign in to comment.