• File: ConversionsTest.js
  • Full Path: /var/www/crm_set/assets/plugins/tinymce/themes/inlite/src/test/js/browser/file/ConversionsTest.js
  • Date Modified: 09/21/2026 4:19 AM
  • File size: 1.04 KB
  • MIME-type: application/javascript
  • Charset: utf-8
asynctest('atomic/core/ConvertTest', [
	'ephox/tinymce',
	'tinymce/inlite/file/Conversions',
	'ephox.agar.api.Step',
	'ephox.agar.api.Pipeline',
	'ephox.agar.api.Assertions'
], function (tinymce, Conversions, Step, Pipeline, Assertions) {
	var success = arguments[arguments.length - 2];
	var failure = arguments[arguments.length - 1];

	var base64ToBlob = function (base64, type) {
		var buff = atob(base64);
		var bytes = new Uint8Array(buff.length);

		for (var i = 0; i < bytes.length; i++) {
			bytes[i] = buff.charCodeAt(i);
		}

		return new Blob([bytes], {type: type});
	};

	var sBlobToBase64 = function () {
		return Step.async(function (next) {
			var base64 = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
			var blob = base64ToBlob(base64, 'image/gif');

			Conversions.blobToBase64(blob).then(function (convertedBase64) {
				Assertions.assertEq(base64, convertedBase64, 'Not the correct base64');
				next();
			});
		});
	};

	Pipeline.async({}, [
		sBlobToBase64()
	], function () {
		success();
	}, function () {
		failure();
	});
});