2
0

util_spec.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. 'use strict';
  16. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  17. var _util = require('../../shared/util');
  18. describe('util', function () {
  19. describe('stringToPDFString', function () {
  20. it('handles ISO Latin 1 strings', function () {
  21. var str = '\x8Dstring\x8E';
  22. expect((0, _util.stringToPDFString)(str)).toEqual('\u201Cstring\u201D');
  23. });
  24. it('handles UTF-16BE strings', function () {
  25. var str = '\xFE\xFF\x00\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67';
  26. expect((0, _util.stringToPDFString)(str)).toEqual('string');
  27. });
  28. it('handles empty strings', function () {
  29. var str1 = '';
  30. expect((0, _util.stringToPDFString)(str1)).toEqual('');
  31. var str2 = '\xFE\xFF';
  32. expect((0, _util.stringToPDFString)(str2)).toEqual('');
  33. });
  34. });
  35. describe('removeNullCharacters', function () {
  36. it('should not modify string without null characters', function () {
  37. var str = 'string without null chars';
  38. expect((0, _util.removeNullCharacters)(str)).toEqual('string without null chars');
  39. });
  40. it('should modify string with null characters', function () {
  41. var str = 'string\x00With\x00Null\x00Chars';
  42. expect((0, _util.removeNullCharacters)(str)).toEqual('stringWithNullChars');
  43. });
  44. });
  45. describe('ReadableStream', function () {
  46. it('should return an Object', function () {
  47. var readable = new _util.ReadableStream();
  48. expect(typeof readable === 'undefined' ? 'undefined' : _typeof(readable)).toEqual('object');
  49. });
  50. it('should have property getReader', function () {
  51. var readable = new _util.ReadableStream();
  52. expect(_typeof(readable.getReader)).toEqual('function');
  53. });
  54. });
  55. });