|
@@ -0,0 +1,80 @@
|
|
|
+/* Copyright 2017 Mozilla Foundation
|
|
|
+ *
|
|
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
+ * you may not use this file except in compliance with the License.
|
|
|
+ * You may obtain a copy of the License at
|
|
|
+ *
|
|
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+ *
|
|
|
+ * Unless required by applicable law or agreed to in writing, software
|
|
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+ * See the License for the specific language governing permissions and
|
|
|
+ * limitations under the License.
|
|
|
+ */
|
|
|
+'use strict';
|
|
|
+
|
|
|
+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; };
|
|
|
+
|
|
|
+var _encodings = require('../../core/encodings');
|
|
|
+
|
|
|
+describe('encodings', function () {
|
|
|
+ describe('getEncoding', function () {
|
|
|
+ it('fetches a valid array for known encoding names', function () {
|
|
|
+ var knownEncodingNames = ['ExpertEncoding', 'MacExpertEncoding', 'MacRomanEncoding', 'StandardEncoding', 'SymbolSetEncoding', 'WinAnsiEncoding', 'ZapfDingbatsEncoding'];
|
|
|
+ var _iteratorNormalCompletion = true;
|
|
|
+ var _didIteratorError = false;
|
|
|
+ var _iteratorError = undefined;
|
|
|
+
|
|
|
+ try {
|
|
|
+ for (var _iterator = knownEncodingNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
|
+ var knownEncodingName = _step.value;
|
|
|
+
|
|
|
+ var encoding = (0, _encodings.getEncoding)(knownEncodingName);
|
|
|
+ expect(Array.isArray(encoding)).toEqual(true);
|
|
|
+ expect(encoding.length).toEqual(256);
|
|
|
+ var _iteratorNormalCompletion2 = true;
|
|
|
+ var _didIteratorError2 = false;
|
|
|
+ var _iteratorError2 = undefined;
|
|
|
+
|
|
|
+ try {
|
|
|
+ for (var _iterator2 = encoding[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
|
+ var item = _step2.value;
|
|
|
+
|
|
|
+ expect(typeof item === 'undefined' ? 'undefined' : _typeof(item)).toEqual('string');
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ _didIteratorError2 = true;
|
|
|
+ _iteratorError2 = err;
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
|
+ _iterator2.return();
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (_didIteratorError2) {
|
|
|
+ throw _iteratorError2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ _didIteratorError = true;
|
|
|
+ _iteratorError = err;
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (!_iteratorNormalCompletion && _iterator.return) {
|
|
|
+ _iterator.return();
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (_didIteratorError) {
|
|
|
+ throw _iteratorError;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ it('fetches `null` for unknown encoding names', function () {
|
|
|
+ expect((0, _encodings.getEncoding)('FooBarEncoding')).toEqual(null);
|
|
|
+ });
|
|
|
+ });
|
|
|
+});
|