UNPKG

3.4 kBJavaScriptView Raw
1/**
2 * @licstart The following is the entire license notice for the
3 * Javascript code in this page
4 *
5 * Copyright 2017 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * Javascript code in this page
21 */
22'use strict';
23
24var _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; };
25
26var _encodings = require('../../core/encodings');
27
28describe('encodings', function () {
29 describe('getEncoding', function () {
30 it('fetches a valid array for known encoding names', function () {
31 var knownEncodingNames = ['ExpertEncoding', 'MacExpertEncoding', 'MacRomanEncoding', 'StandardEncoding', 'SymbolSetEncoding', 'WinAnsiEncoding', 'ZapfDingbatsEncoding'];
32 var _iteratorNormalCompletion = true;
33 var _didIteratorError = false;
34 var _iteratorError = undefined;
35
36 try {
37 for (var _iterator = knownEncodingNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
38 var knownEncodingName = _step.value;
39
40 var encoding = (0, _encodings.getEncoding)(knownEncodingName);
41 expect(Array.isArray(encoding)).toEqual(true);
42 expect(encoding.length).toEqual(256);
43 var _iteratorNormalCompletion2 = true;
44 var _didIteratorError2 = false;
45 var _iteratorError2 = undefined;
46
47 try {
48 for (var _iterator2 = encoding[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
49 var item = _step2.value;
50
51 expect(typeof item === 'undefined' ? 'undefined' : _typeof(item)).toEqual('string');
52 }
53 } catch (err) {
54 _didIteratorError2 = true;
55 _iteratorError2 = err;
56 } finally {
57 try {
58 if (!_iteratorNormalCompletion2 && _iterator2.return) {
59 _iterator2.return();
60 }
61 } finally {
62 if (_didIteratorError2) {
63 throw _iteratorError2;
64 }
65 }
66 }
67 }
68 } catch (err) {
69 _didIteratorError = true;
70 _iteratorError = err;
71 } finally {
72 try {
73 if (!_iteratorNormalCompletion && _iterator.return) {
74 _iterator.return();
75 }
76 } finally {
77 if (_didIteratorError) {
78 throw _iteratorError;
79 }
80 }
81 }
82 });
83 it('fetches `null` for unknown encoding names', function () {
84 expect((0, _encodings.getEncoding)('FooBarEncoding')).toEqual(null);
85 });
86 });
87});
\No newline at end of file