@tolgee/core 2.8.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/tolgee.cjs.js +4506 -4023
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/tolgee.esm.js +1 -1
- package/dist/tolgee.esm.js.map +1 -1
- package/dist/tolgee.umd.js +4506 -4023
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +1 -1
- package/dist/tolgee.umd.min.js.map +1 -1
- package/lib/Observer.d.ts +3 -7
- package/lib/Observer.js +5 -7
- package/lib/Observer.js.map +1 -1
- package/lib/Properties.js +8 -2
- package/lib/Properties.js.map +1 -1
- package/lib/Tolgee.d.ts +8 -4
- package/lib/Tolgee.js +48 -26
- package/lib/Tolgee.js.map +1 -1
- package/lib/TolgeeConfig.d.ts +1 -0
- package/lib/TolgeeConfig.js +1 -0
- package/lib/TolgeeConfig.js.map +1 -1
- package/lib/helpers/NodeHelper.d.ts +2 -0
- package/lib/helpers/NodeHelper.js +6 -0
- package/lib/helpers/NodeHelper.js.map +1 -1
- package/lib/helpers/encoderPolyfill.d.ts +8 -0
- package/lib/helpers/encoderPolyfill.js +96 -0
- package/lib/helpers/encoderPolyfill.js.map +1 -0
- package/lib/helpers/secret.d.ts +6 -0
- package/lib/helpers/secret.js +73 -0
- package/lib/helpers/secret.js.map +1 -0
- package/lib/highlighter/MouseEventHandler.d.ts +6 -5
- package/lib/highlighter/MouseEventHandler.js +32 -29
- package/lib/highlighter/MouseEventHandler.js.map +1 -1
- package/lib/highlighter/TranslationHighlighter.d.ts +2 -2
- package/lib/highlighter/TranslationHighlighter.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/modules/IcuFormatter.d.ts +2 -0
- package/lib/modules/IcuFormatter.js +14 -0
- package/lib/modules/IcuFormatter.js.map +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/modules/index.js.map +1 -0
- package/lib/services/{DependencyStore.d.ts → DependencyService.d.ts} +10 -11
- package/lib/services/{DependencyStore.js → DependencyService.js} +34 -18
- package/lib/services/DependencyService.js.map +1 -0
- package/lib/services/ModuleService.d.ts +5 -0
- package/lib/services/ModuleService.js +18 -0
- package/lib/services/ModuleService.js.map +1 -0
- package/lib/services/TextService.d.ts +6 -14
- package/lib/services/TextService.js +29 -223
- package/lib/services/TextService.js.map +1 -1
- package/lib/services/TranslationService.d.ts +4 -2
- package/lib/services/TranslationService.js +9 -11
- package/lib/services/TranslationService.js.map +1 -1
- package/lib/types.d.ts +18 -0
- package/lib/wrappers/AbstractWrapper.d.ts +8 -0
- package/lib/wrappers/AbstractWrapper.js +2 -0
- package/lib/wrappers/AbstractWrapper.js.map +1 -0
- package/lib/wrappers/NodeHandler.d.ts +18 -0
- package/lib/{handlers/AbstractHandler.js → wrappers/NodeHandler.js} +18 -19
- package/lib/wrappers/NodeHandler.js.map +1 -0
- package/lib/wrappers/WrappedHandler.d.ts +8 -0
- package/lib/{handlers → wrappers}/WrappedHandler.js +8 -28
- package/lib/wrappers/WrappedHandler.js.map +1 -0
- package/lib/wrappers/invisible/AttributeHandler.d.ts +8 -0
- package/lib/wrappers/invisible/AttributeHandler.js +134 -0
- package/lib/wrappers/invisible/AttributeHandler.js.map +1 -0
- package/lib/wrappers/invisible/Coder.d.ts +7 -0
- package/lib/wrappers/invisible/Coder.js +110 -0
- package/lib/wrappers/invisible/Coder.js.map +1 -0
- package/lib/wrappers/invisible/ContentHandler.d.ts +6 -0
- package/lib/{services/DependencyStore.test.js → wrappers/invisible/ContentHandler.js} +26 -30
- package/lib/wrappers/invisible/ContentHandler.js.map +1 -0
- package/lib/wrappers/invisible/CoreHandler.d.ts +10 -0
- package/lib/{services/__mocks__/CoreService.js → wrappers/invisible/CoreHandler.js} +27 -12
- package/lib/wrappers/invisible/CoreHandler.js.map +1 -0
- package/lib/wrappers/invisible/InvisibleWrapper.d.ts +18 -0
- package/lib/wrappers/invisible/InvisibleWrapper.js +37 -0
- package/lib/wrappers/invisible/InvisibleWrapper.js.map +1 -0
- package/lib/wrappers/invisible/ValueMemory.d.ts +5 -0
- package/lib/wrappers/invisible/ValueMemory.js +19 -0
- package/lib/wrappers/invisible/ValueMemory.js.map +1 -0
- package/lib/wrappers/text/AttributeHandler.d.ts +8 -0
- package/lib/{handlers → wrappers/text}/AttributeHandler.js +7 -28
- package/lib/wrappers/text/AttributeHandler.js.map +1 -0
- package/lib/wrappers/text/Coder.d.ts +15 -0
- package/lib/wrappers/text/Coder.js +248 -0
- package/lib/wrappers/text/Coder.js.map +1 -0
- package/lib/wrappers/text/ContentHandler.d.ts +8 -0
- package/lib/{handlers/TextHandler.js → wrappers/text/ContentHandler.js} +12 -33
- package/lib/wrappers/text/ContentHandler.js.map +1 -0
- package/lib/wrappers/text/CoreHandler.d.ts +17 -0
- package/lib/{handlers → wrappers/text}/CoreHandler.js +5 -6
- package/lib/wrappers/text/CoreHandler.js.map +1 -0
- package/lib/wrappers/text/TextWrapper.d.ts +20 -0
- package/lib/wrappers/text/TextWrapper.js +36 -0
- package/lib/wrappers/text/TextWrapper.js.map +1 -0
- package/package.json +6 -5
- package/lib/Observer.test.d.ts +0 -2
- package/lib/Observer.test.js +0 -190
- package/lib/Observer.test.js.map +0 -1
- package/lib/Properties.test.d.ts +0 -1
- package/lib/Properties.test.js +0 -77
- package/lib/Properties.test.js.map +0 -1
- package/lib/Tolgee.test.d.ts +0 -1
- package/lib/Tolgee.test.js +0 -482
- package/lib/Tolgee.test.js.map +0 -1
- package/lib/TolgeeConfig.test.d.ts +0 -1
- package/lib/TolgeeConfig.test.js +0 -18
- package/lib/TolgeeConfig.test.js.map +0 -1
- package/lib/__testFixtures/classMock.d.ts +0 -3
- package/lib/__testFixtures/classMock.js +0 -8
- package/lib/__testFixtures/classMock.js.map +0 -1
- package/lib/__testFixtures/createElement.d.ts +0 -2
- package/lib/__testFixtures/createElement.js +0 -58
- package/lib/__testFixtures/createElement.js.map +0 -1
- package/lib/__testFixtures/createTestDom.d.ts +0 -9
- package/lib/__testFixtures/createTestDom.js +0 -18
- package/lib/__testFixtures/createTestDom.js.map +0 -1
- package/lib/__testFixtures/mocked.d.ts +0 -20
- package/lib/__testFixtures/mocked.js +0 -24
- package/lib/__testFixtures/mocked.js.map +0 -1
- package/lib/__testFixtures/setupAfterEnv.d.ts +0 -8
- package/lib/__testFixtures/setupAfterEnv.js +0 -23
- package/lib/__testFixtures/setupAfterEnv.js.map +0 -1
- package/lib/handlers/AbstractHandler.d.ts +0 -21
- package/lib/handlers/AbstractHandler.js.map +0 -1
- package/lib/handlers/AttributeHandler.d.ts +0 -13
- package/lib/handlers/AttributeHandler.js.map +0 -1
- package/lib/handlers/AttributeHandler.test.d.ts +0 -1
- package/lib/handlers/AttributeHandler.test.js +0 -177
- package/lib/handlers/AttributeHandler.test.js.map +0 -1
- package/lib/handlers/CoreHandler.d.ts +0 -19
- package/lib/handlers/CoreHandler.js.map +0 -1
- package/lib/handlers/CoreHandler.test.d.ts +0 -1
- package/lib/handlers/CoreHandler.test.js +0 -148
- package/lib/handlers/CoreHandler.test.js.map +0 -1
- package/lib/handlers/TextHandler.d.ts +0 -13
- package/lib/handlers/TextHandler.js.map +0 -1
- package/lib/handlers/TextHandler.test.d.ts +0 -1
- package/lib/handlers/TextHandler.test.js +0 -270
- package/lib/handlers/TextHandler.test.js.map +0 -1
- package/lib/handlers/WrappedHandler.d.ts +0 -13
- package/lib/handlers/WrappedHandler.js.map +0 -1
- package/lib/helpers/TextHelper.test.d.ts +0 -1
- package/lib/helpers/TextHelper.test.js +0 -107
- package/lib/helpers/TextHelper.test.js.map +0 -1
- package/lib/highlighter/HighlightFunctionsInitializer.test.d.ts +0 -1
- package/lib/highlighter/HighlightFunctionsInitializer.test.js +0 -81
- package/lib/highlighter/HighlightFunctionsInitializer.test.js.map +0 -1
- package/lib/highlighter/MouseEventHandler.test.d.ts +0 -1
- package/lib/highlighter/MouseEventHandler.test.js +0 -215
- package/lib/highlighter/MouseEventHandler.test.js.map +0 -1
- package/lib/highlighter/TranslationHighlighter.test.d.ts +0 -1
- package/lib/highlighter/TranslationHighlighter.test.js +0 -287
- package/lib/highlighter/TranslationHighlighter.test.js.map +0 -1
- package/lib/services/CoreService.test.d.ts +0 -1
- package/lib/services/CoreService.test.js +0 -178
- package/lib/services/CoreService.test.js.map +0 -1
- package/lib/services/DependencyStore.js.map +0 -1
- package/lib/services/DependencyStore.test.d.ts +0 -1
- package/lib/services/DependencyStore.test.js.map +0 -1
- package/lib/services/ElementRegistrar.test.d.ts +0 -1
- package/lib/services/ElementRegistrar.test.js +0 -215
- package/lib/services/ElementRegistrar.test.js.map +0 -1
- package/lib/services/TextService.test.d.ts +0 -1
- package/lib/services/TextService.test.js +0 -430
- package/lib/services/TextService.test.js.map +0 -1
- package/lib/services/TranslationService.test.d.ts +0 -1
- package/lib/services/TranslationService.test.js +0 -649
- package/lib/services/TranslationService.test.js.map +0 -1
- package/lib/services/__mocks__/CoreService.d.ts +0 -2
- package/lib/services/__mocks__/CoreService.js.map +0 -1
- package/lib/toolsManager/Messages.test.d.ts +0 -1
- package/lib/toolsManager/Messages.test.js +0 -114
- package/lib/toolsManager/Messages.test.js.map +0 -1
- package/lib/toolsManager/PluginManager.test.d.ts +0 -1
- package/lib/toolsManager/PluginManager.test.js +0 -120
- package/lib/toolsManager/PluginManager.test.js.map +0 -1
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
-
if (!m) return o;
|
|
40
|
-
var i = m.call(o), r, ar = [], e;
|
|
41
|
-
try {
|
|
42
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
-
}
|
|
44
|
-
catch (error) { e = { error: error }; }
|
|
45
|
-
finally {
|
|
46
|
-
try {
|
|
47
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
-
}
|
|
49
|
-
finally { if (e) throw e.error; }
|
|
50
|
-
}
|
|
51
|
-
return ar;
|
|
52
|
-
};
|
|
53
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
-
if (ar || !(i in from)) {
|
|
56
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
-
ar[i] = from[i];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
-
};
|
|
62
|
-
jest.dontMock('./TextHandler');
|
|
63
|
-
jest.dontMock('./AbstractHandler');
|
|
64
|
-
jest.dontMock('../services/EventService');
|
|
65
|
-
jest.dontMock('../helpers/NodeHelper.ts');
|
|
66
|
-
jest.dontMock('../services/DependencyStore');
|
|
67
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
68
|
-
import { NodeHelper } from '../helpers/NodeHelper';
|
|
69
|
-
import { createTestDom } from '@testFixtures/createTestDom';
|
|
70
|
-
import { TextService } from '../services/TextService';
|
|
71
|
-
import { getMockedInstance } from '@testFixtures/mocked';
|
|
72
|
-
import { ElementRegistrar } from '../services/ElementRegistrar';
|
|
73
|
-
import { Properties } from '../Properties';
|
|
74
|
-
import { DependencyStore } from '../services/DependencyStore';
|
|
75
|
-
describe('TextHandler', function () {
|
|
76
|
-
var textHandler;
|
|
77
|
-
var mockedKeys = [
|
|
78
|
-
{
|
|
79
|
-
key: 'dummyKey',
|
|
80
|
-
params: { dummyParam: 'dummyValue' },
|
|
81
|
-
},
|
|
82
|
-
];
|
|
83
|
-
var mockedTranslateInner = function (text) {
|
|
84
|
-
return {
|
|
85
|
-
text: text.replace(/{{(.*?)}}/gs, 'translated $1'),
|
|
86
|
-
keys: mockedKeys,
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
var gv = function (key) { return mockedTranslateInner(key).text; };
|
|
90
|
-
var mockedTranslate = jest.fn(mockedTranslateInner);
|
|
91
|
-
var c;
|
|
92
|
-
beforeEach(function () {
|
|
93
|
-
textHandler = new DependencyStore().textHandler;
|
|
94
|
-
getMockedInstance(Properties).config = {
|
|
95
|
-
inputPrefix: '{{',
|
|
96
|
-
inputSuffix: '}}',
|
|
97
|
-
restrictedElements: [],
|
|
98
|
-
tagAttributes: {
|
|
99
|
-
'*': ['aria-label'],
|
|
100
|
-
},
|
|
101
|
-
passToParent: ['option'],
|
|
102
|
-
};
|
|
103
|
-
c = createTestDom(document);
|
|
104
|
-
getMockedInstance(TextService).replace = function () {
|
|
105
|
-
var args = [];
|
|
106
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
107
|
-
args[_i] = arguments[_i];
|
|
108
|
-
}
|
|
109
|
-
return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
110
|
-
return [2 /*return*/, mockedTranslate.apply(void 0, __spreadArray([], __read(args), false))];
|
|
111
|
-
}); });
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
jest.clearAllMocks();
|
|
117
|
-
return [2 /*return*/];
|
|
118
|
-
});
|
|
119
|
-
}); });
|
|
120
|
-
describe('in production mode', function () {
|
|
121
|
-
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
-
return __generator(this, function (_a) {
|
|
123
|
-
switch (_a.label) {
|
|
124
|
-
case 0: return [4 /*yield*/, textHandler.handle(document.body)];
|
|
125
|
-
case 1:
|
|
126
|
-
_a.sent();
|
|
127
|
-
return [2 /*return*/];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}); });
|
|
131
|
-
test('Can be created', function () {
|
|
132
|
-
expect(textHandler).not.toBeUndefined();
|
|
133
|
-
});
|
|
134
|
-
test('will handle text in root', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
135
|
-
return __generator(this, function (_a) {
|
|
136
|
-
expect("./text()[contains(., ".concat(gv(c.keyInRoot), ")]")).toBeFoundIn(document.body);
|
|
137
|
-
return [2 /*return*/];
|
|
138
|
-
});
|
|
139
|
-
}); });
|
|
140
|
-
test('will handle text in div', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
-
return __generator(this, function (_a) {
|
|
142
|
-
expect("./div/text()[contains(., 'Some trash... translated ".concat(gv(c.keyInRootDiv), "')]")).toBeFoundIn(document.body);
|
|
143
|
-
return [2 /*return*/];
|
|
144
|
-
});
|
|
145
|
-
}); });
|
|
146
|
-
test('will handle text in div > div > span', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
-
var xpath;
|
|
148
|
-
return __generator(this, function (_a) {
|
|
149
|
-
xpath = "./div/div/span/text()[contains(., 'translated ".concat(gv(c.hereKey), " and translated ").concat(gv(c.hereTooKey), "')]");
|
|
150
|
-
expect(xpath).toBeFoundIn(document.body);
|
|
151
|
-
return [2 /*return*/];
|
|
152
|
-
});
|
|
153
|
-
}); });
|
|
154
|
-
describe("Node's _tolgee property", function () {
|
|
155
|
-
var node;
|
|
156
|
-
beforeEach(function () {
|
|
157
|
-
node = NodeHelper.evaluateToSingle("./text()[contains(., ".concat(gv(c.keyInRoot), ")]"), document.body);
|
|
158
|
-
});
|
|
159
|
-
test('will be defined', function () {
|
|
160
|
-
expect(node._tolgee).toBeDefined();
|
|
161
|
-
});
|
|
162
|
-
test('will have proper oldTextContent', function () {
|
|
163
|
-
expect(node._tolgee.oldTextContent).toContain("{{".concat(c.keyInRoot, "}}"));
|
|
164
|
-
});
|
|
165
|
-
test('will have proper keys length', function () {
|
|
166
|
-
expect(node._tolgee.keys).toHaveLength(1);
|
|
167
|
-
});
|
|
168
|
-
test('will have proper first key', function () {
|
|
169
|
-
expect(node._tolgee.keys).toEqual(mockedKeys);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
test('will lock the node', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
-
var node, resolve, promise;
|
|
174
|
-
return __generator(this, function (_a) {
|
|
175
|
-
switch (_a.label) {
|
|
176
|
-
case 0:
|
|
177
|
-
c = createTestDom(document);
|
|
178
|
-
node = NodeHelper.evaluateToSingle("./text()[contains(., ".concat(gv(c.keyInRoot), ")]"), document.body);
|
|
179
|
-
getMockedInstance(TextService).replace = function () {
|
|
180
|
-
return new Promise(function (r) { return (resolve = r); });
|
|
181
|
-
};
|
|
182
|
-
promise = textHandler.handle(node);
|
|
183
|
-
return [4 /*yield*/, new Promise(function (r) { return setTimeout(r); })];
|
|
184
|
-
case 1:
|
|
185
|
-
_a.sent();
|
|
186
|
-
expect(node._tolgee.locked).toEqual(true);
|
|
187
|
-
resolve();
|
|
188
|
-
return [4 /*yield*/, promise];
|
|
189
|
-
case 2:
|
|
190
|
-
_a.sent();
|
|
191
|
-
expect(node._tolgee.locked).toEqual(false);
|
|
192
|
-
return [2 /*return*/];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}); });
|
|
196
|
-
describe("Parent element's _tolgee property and attribute", function () {
|
|
197
|
-
var element;
|
|
198
|
-
var node;
|
|
199
|
-
beforeEach(function () {
|
|
200
|
-
node = NodeHelper.evaluateToSingle("./text()[contains(., ".concat(gv(c.keyInRoot), ")]"), document.body);
|
|
201
|
-
element = node.parentElement;
|
|
202
|
-
});
|
|
203
|
-
test('property will be defined', function () {
|
|
204
|
-
expect(element._tolgee).toBeDefined();
|
|
205
|
-
});
|
|
206
|
-
test('will contain nodes array with correct node', function () {
|
|
207
|
-
expect(element._tolgee.nodes).toEqual(new Set([node]));
|
|
208
|
-
});
|
|
209
|
-
test('attribute will be set', function () {
|
|
210
|
-
expect(element.getAttribute('_tolgee')).toEqual('');
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
test("will pass option's text node to select element", function () {
|
|
214
|
-
var xPath = "//text()[contains(., 'translated option_key')]";
|
|
215
|
-
var node = NodeHelper.evaluateToSingle(xPath, document.body);
|
|
216
|
-
expect(node.parentElement.parentElement).toHaveAttribute('_tolgee', '');
|
|
217
|
-
expect(node.parentElement).not.toHaveAttribute('_tolgee');
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
test('will pass recursively', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
221
|
-
var xPath, node;
|
|
222
|
-
return __generator(this, function (_a) {
|
|
223
|
-
switch (_a.label) {
|
|
224
|
-
case 0:
|
|
225
|
-
getMockedInstance(Properties).config.passToParent = ['option', 'select'];
|
|
226
|
-
return [4 /*yield*/, textHandler.handle(document.body)];
|
|
227
|
-
case 1:
|
|
228
|
-
_a.sent();
|
|
229
|
-
xPath = "//text()[contains(., 'translated option_key')]";
|
|
230
|
-
node = NodeHelper.evaluateToSingle(xPath, document.body);
|
|
231
|
-
expect(node.parentElement.parentElement.parentElement).toHaveAttribute('_tolgee', '');
|
|
232
|
-
expect(node.parentElement.parentElement).not.toHaveAttribute('_tolgee');
|
|
233
|
-
return [2 /*return*/];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}); });
|
|
237
|
-
test('will pass with function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
238
|
-
var xPath, node;
|
|
239
|
-
return __generator(this, function (_a) {
|
|
240
|
-
switch (_a.label) {
|
|
241
|
-
case 0:
|
|
242
|
-
getMockedInstance(Properties).config.passToParent = function (element) {
|
|
243
|
-
return element.tagName === 'OPTION';
|
|
244
|
-
};
|
|
245
|
-
return [4 /*yield*/, textHandler.handle(document.body)];
|
|
246
|
-
case 1:
|
|
247
|
-
_a.sent();
|
|
248
|
-
xPath = "//text()[contains(., 'translated option_key')]";
|
|
249
|
-
node = NodeHelper.evaluateToSingle(xPath, document.body);
|
|
250
|
-
expect(node.parentElement.parentElement).toHaveAttribute('_tolgee', '');
|
|
251
|
-
expect(node.parentElement).not.toHaveAttribute('_tolgee');
|
|
252
|
-
return [2 /*return*/];
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}); });
|
|
256
|
-
test('will register the node', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
257
|
-
var node;
|
|
258
|
-
return __generator(this, function (_a) {
|
|
259
|
-
switch (_a.label) {
|
|
260
|
-
case 0: return [4 /*yield*/, textHandler.handle(document.body)];
|
|
261
|
-
case 1:
|
|
262
|
-
_a.sent();
|
|
263
|
-
node = NodeHelper.evaluateToSingle("./text()[contains(., ".concat(gv(c.keyInRoot), ")]"), document.body);
|
|
264
|
-
expect(getMockedInstance(ElementRegistrar).register).toBeCalledWith(node.parentElement);
|
|
265
|
-
return [2 /*return*/];
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}); });
|
|
269
|
-
});
|
|
270
|
-
//# sourceMappingURL=TextHandler.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextHandler.test.js","sourceRoot":"","sources":["../../src/handlers/TextHandler.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC/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C;;;;SACzE,CAAC,CAAC;IAEH,IAAI,CAAC,yBAAyB,EAAE;;;;;oBAC9B,iBAAiB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,YAAY,GAAG,UAAC,OAAO;wBAC1D,OAAA,OAAO,CAAC,OAAO,KAAK,QAAQ;oBAA5B,CAA4B,CAAC;oBAC/B,qBAAM,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAA;;oBAAvC,SAAuC,CAAC;oBAClC,KAAK,GAAG,gDAAgD,CAAC;oBACzD,IAAI,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC/D,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,eAAe,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;oBACxE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;;;;SAC3D,CAAC,CAAC;IAEH,IAAI,CAAC,wBAAwB,EAAE;;;;wBAC7B,qBAAM,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAA;;oBAAvC,SAAuC,CAAC;oBAClC,IAAI,GAAG,UAAU,CAAC,gBAAgB,CACtC,+BAAwB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,OAAI,EAC3C,QAAQ,CAAC,IAAI,CACd,CAAC;oBACF,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,cAAc,CACjE,IAAI,CAAC,aAAa,CACnB,CAAC;;;;SACH,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Properties } from '../Properties';
|
|
2
|
-
import { TranslationHighlighter } from '../highlighter/TranslationHighlighter';
|
|
3
|
-
import { TextService } from '../services/TextService';
|
|
4
|
-
import { AbstractHandler } from './AbstractHandler';
|
|
5
|
-
import { ElementRegistrar } from '../services/ElementRegistrar';
|
|
6
|
-
export declare class WrappedHandler extends AbstractHandler {
|
|
7
|
-
protected properties: Properties;
|
|
8
|
-
protected translationHighlighter: TranslationHighlighter;
|
|
9
|
-
protected textService: TextService;
|
|
10
|
-
protected elementRegistrar: ElementRegistrar;
|
|
11
|
-
constructor(properties: Properties, translationHighlighter: TranslationHighlighter, textService: TextService, elementRegistrar: ElementRegistrar);
|
|
12
|
-
handle(node: Node): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrappedHandler.js","sourceRoot":"","sources":["../../src/handlers/WrappedHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAEzE;IAAoC,kCAAe;IACjD,wBACY,UAAsB,EACtB,sBAA8C,EAC9C,WAAwB,EACxB,gBAAkC;QAJ9C,YAME,kBAAM,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,SACzE;QANW,gBAAU,GAAV,UAAU,CAAY;QACtB,4BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,iBAAW,GAAX,WAAW,CAAa;QACxB,sBAAgB,GAAhB,gBAAgB,CAAkB;;IAG9C,CAAC;IAEK,+BAAM,GAAZ,UAAa,IAAU;;;;;gBACf,KAAK,GAAG,mCAA4B,kCAAkC,MAAG,CAAC;gBAC1E,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBACzC,QAAQ,GAAc,IAAI,CAAC,gBAAgB,CAAC,KAAkB,CAAC,CAAC;gBACtE,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO;oBACvB,IAAM,eAAe,GAAG,eAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;oBACnE,eAAe,CAAC,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,YAAY,CACtE,kCAAkC,CACnC,CAAC;oBACF,eAAe,CAAC,OAAO,CAAC,iCAAiC;wBACvD,OAAO,CAAC,SAAS,CAAC;oBACpB,KAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;gBAClD,CAAC,CAAC,CAAC;;;;KACJ;IACH,qBAAC;AAAD,CAAC,AAxBD,CAAoC,eAAe,GAwBlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
jest.dontMock('./TextHelper');
|
|
38
|
-
import { TextHelper } from './TextHelper';
|
|
39
|
-
describe('TextHelper', function () {
|
|
40
|
-
describe('will split', function () {
|
|
41
|
-
test('on non escaped properly', function () {
|
|
42
|
-
var strings = TextHelper.splitOnNonEscapedDelimiter('text.to.split', '.');
|
|
43
|
-
expect(strings).toEqual(['text', 'to', 'split']);
|
|
44
|
-
});
|
|
45
|
-
test('on escaped and non escaped properly', function () {
|
|
46
|
-
var strings = TextHelper.splitOnNonEscapedDelimiter('text\\.to\\.split', '.');
|
|
47
|
-
expect(strings).toEqual(['text.to.split']);
|
|
48
|
-
});
|
|
49
|
-
test('empty string properly', function () {
|
|
50
|
-
var strings = TextHelper.splitOnNonEscapedDelimiter('', '.');
|
|
51
|
-
expect(strings).toEqual(['']);
|
|
52
|
-
});
|
|
53
|
-
test('correctly when it begins with escape', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
-
var strings;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
strings = TextHelper.splitOnNonEscapedDelimiter('\\.aa', '.');
|
|
57
|
-
expect(strings).toEqual(['.aa']);
|
|
58
|
-
return [2 /*return*/];
|
|
59
|
-
});
|
|
60
|
-
}); });
|
|
61
|
-
test('correctly when it ends with escape', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var strings;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
strings = TextHelper.splitOnNonEscapedDelimiter('aa\\.', '.');
|
|
65
|
-
expect(strings).toEqual(['aa.']);
|
|
66
|
-
return [2 /*return*/];
|
|
67
|
-
});
|
|
68
|
-
}); });
|
|
69
|
-
test('correctly when it contains escaped escape character', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
-
var strings;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
strings = TextHelper.splitOnNonEscapedDelimiter('aa\\\\.', '.');
|
|
73
|
-
expect(strings).toEqual(['aa\\', '']);
|
|
74
|
-
return [2 /*return*/];
|
|
75
|
-
});
|
|
76
|
-
}); });
|
|
77
|
-
test('correctly when it contains escaped escape character and delimiter is escaped', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var strings;
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
strings = TextHelper.splitOnNonEscapedDelimiter('aa\\\\\\.', '.');
|
|
81
|
-
expect(strings).toEqual(['aa\\.']);
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
});
|
|
84
|
-
}); });
|
|
85
|
-
});
|
|
86
|
-
describe('It remove escapes', function () {
|
|
87
|
-
test('basically', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
expect(TextHelper.removeEscapes('t\\t')).toEqual('tt');
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
});
|
|
92
|
-
}); });
|
|
93
|
-
test('not if escape character is escaped', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
-
return __generator(this, function (_a) {
|
|
95
|
-
expect(TextHelper.removeEscapes('\\\\')).toEqual('\\');
|
|
96
|
-
return [2 /*return*/];
|
|
97
|
-
});
|
|
98
|
-
}); });
|
|
99
|
-
test('if there is escaped escaped character', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
expect(TextHelper.removeEscapes('\\\\\\')).toEqual('\\');
|
|
102
|
-
return [2 /*return*/];
|
|
103
|
-
});
|
|
104
|
-
}); });
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
//# sourceMappingURL=TextHelper.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextHelper.test.js","sourceRoot":"","sources":["../../src/helpers/TextHelper.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,QAAQ,CAAC,YAAY,EAAE;IACrB,QAAQ,CAAC,YAAY,EAAE;QACrB,IAAI,CAAC,yBAAyB,EAAE;YAC9B,IAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,CACnD,eAAe,EACf,GAAG,CACJ,CAAC;YACF,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,qCAAqC,EAAE;YAC1C,IAA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ACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,mBAAmB,EAAE;QAC5B,IAAI,CAAC,WAAW,EAAE;;gBAChB,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;;aACxD,CAAC,CAAC;QAEH,IAAI,CAAC,oCAAoC,EAAE;;gBACzC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;;aACxD,CAAC,CAAC;QAEH,IAAI,CAAC,uCAAuC,EAAE;;gBAC5C,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;;aAC1D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
jest.dontMock('./HighlightFunctionsInitializer');
|
|
38
|
-
jest.dontMock('../services/DependencyStore');
|
|
39
|
-
import { getMockedInstance } from '@testFixtures/mocked';
|
|
40
|
-
import { Properties } from '../Properties';
|
|
41
|
-
import { DependencyStore } from '../services/DependencyStore';
|
|
42
|
-
describe('HighlightFunctionsInitializer', function () {
|
|
43
|
-
var highlightFunctionInitializer;
|
|
44
|
-
var mockedElement;
|
|
45
|
-
var mockedColor = 'rgb(0, 30, 50)';
|
|
46
|
-
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
highlightFunctionInitializer = new DependencyStore()
|
|
50
|
-
.highlightFunctionInitializer;
|
|
51
|
-
mockedElement = document.createElement('div');
|
|
52
|
-
getMockedInstance(Properties).config.highlightColor = mockedColor;
|
|
53
|
-
mockedElement._tolgee = {};
|
|
54
|
-
highlightFunctionInitializer.initFunctions(mockedElement);
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
});
|
|
57
|
-
}); });
|
|
58
|
-
afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
return __generator(this, function (_a) {
|
|
60
|
-
jest.clearAllMocks();
|
|
61
|
-
return [2 /*return*/];
|
|
62
|
-
});
|
|
63
|
-
}); });
|
|
64
|
-
test('Will reset to correct initial color', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
mockedElement.style.backgroundColor = '#222222';
|
|
67
|
-
mockedElement._tolgee.highlight();
|
|
68
|
-
mockedElement._tolgee.unhighlight();
|
|
69
|
-
expect(mockedElement.style.backgroundColor).toEqual('rgb(34, 34, 34)');
|
|
70
|
-
return [2 /*return*/];
|
|
71
|
-
});
|
|
72
|
-
}); });
|
|
73
|
-
test('Will highlight', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
mockedElement._tolgee.highlight();
|
|
76
|
-
expect(mockedElement.style.backgroundColor).toEqual(mockedColor);
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
});
|
|
79
|
-
}); });
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=HighlightFunctionsInitializer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightFunctionsInitializer.test.js","sourceRoot":"","sources":["../../src/highlighter/HighlightFunctionsInitializer.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC;AACjD,IAAI,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AAG7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,QAAQ,CAAC,+BAA+B,EAAE;IACxC,IAAI,4BAA2D,CAAC;IAChE,IAAI,aAA8B,CAAC;IACnC,IAAM,WAAW,GAAG,gBAAgB,CAAC;IAErC,UAAU,CAAC;;YACT,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,4BAA4B,GAAG,IAAI,eAAe,EAAE;iBACjD,4BAA4B,CAAC;YAChC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAA+B,CAAC;YAC5E,iBAAiB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,cAAc,GAAG,WAAW,CAAC;YACjE,aAAa,CAAC,OAAe,GAAG,EAAE,CAAC;YACpC,4BAA4B,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;;;SAC3D,CAAC,CAAC;IAEH,SAAS,CAAC;;YACR,IAAI,CAAC,aAAa,EAAE,CAAC;;;SACtB,CAAC,CAAC;IAEH,IAAI,CAAC,qCAAqC,EAAE;;YAC1C,aAAa,CAAC,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC;YAChD,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YAClC,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACpC,MAAM,CAAC,aAAa,CAAC,KAAK,CAA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