testaro 27.0.0 → 28.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/CONTRIBUTING.md +3 -1
- package/README.md +14 -3
- package/package.json +2 -1
- package/procs/aslint.js +83 -0
- package/procs/nav.js +56 -14
- package/procs/standardize.js +36 -0
- package/run.js +35 -22
- package/tests/aslint.js +83 -0
- package/tests/axe.js +4 -0
- package/tests/qualWeb.js +6 -0
- package/aslint/LICENSE +0 -362
- package/aslint/README.md +0 -260
- package/aslint/app/rules/abstract-rule.ts +0 -83
- package/aslint/app/rules/aslint/incorrect-technique-for-hiding-content/incorrect-technique-for-hiding-content.documentation.md +0 -36
- package/aslint/app/rules/aslint/incorrect-technique-for-hiding-content/incorrect-technique-for-hiding-content.test.ts +0 -113
- package/aslint/app/rules/aslint/incorrect-technique-for-hiding-content/incorrect-technique-for-hiding-content.ts +0 -103
- package/aslint/app/rules/aslint/invalid-attribute-dir-value/invalid-attribute-dir-value.documentation.md +0 -34
- package/aslint/app/rules/aslint/invalid-attribute-dir-value/invalid-attribute-dir-value.test.ts +0 -82
- package/aslint/app/rules/aslint/invalid-attribute-dir-value/invalid-attribute-dir-value.ts +0 -44
- package/aslint/app/rules/aslint/label-duplicated-content-title/label-duplicated-content-title.documentation.md +0 -40
- package/aslint/app/rules/aslint/label-duplicated-content-title/label-duplicated-content-title.test.ts +0 -48
- package/aslint/app/rules/aslint/label-duplicated-content-title/label-duplicated-content-title.ts +0 -37
- package/aslint/app/rules/aslint/links-language-destination/links-language-destination.test.ts +0 -50
- package/aslint/app/rules/aslint/links-language-destination/links-language-destination.ts +0 -70
- package/aslint/app/rules/aslint/main-element-only-one/main-element-only-one.test.ts +0 -55
- package/aslint/app/rules/aslint/main-element-only-one/main-element-only-one.ts +0 -83
- package/aslint/app/rules/aslint/main-landmark-must-be-top-level/main-landmark-must-be-top-level.test.ts +0 -12
- package/aslint/app/rules/aslint/main-landmark-must-be-top-level/main-landmark-must-be-top-level.ts +0 -73
- package/aslint/app/rules/aslint/minimum-font-size/minimum-font-size.test.ts +0 -12
- package/aslint/app/rules/aslint/minimum-font-size/minimum-font-size.ts +0 -87
- package/aslint/app/rules/aslint/missing-href-on-a/missing-href-on-a.test.ts +0 -48
- package/aslint/app/rules/aslint/missing-href-on-a/missing-href-on-a.ts +0 -40
- package/aslint/app/rules/aslint/misused-aria-on-focusable-element/misused-aria-on-focusable-element.test.ts +0 -12
- package/aslint/app/rules/aslint/misused-aria-on-focusable-element/misused-aria-on-focusable-element.ts +0 -66
- package/aslint/app/rules/aslint/misused-input-attribute/misused-input-attribute.test.ts +0 -12
- package/aslint/app/rules/aslint/misused-input-attribute/misused-input-attribute.ts +0 -134
- package/aslint/app/rules/aslint/misused-required-attribute/misused-required-attribute.test.ts +0 -12
- package/aslint/app/rules/aslint/misused-required-attribute/misused-required-attribute.ts +0 -90
- package/aslint/app/rules/aslint/navigation-landmark-restrictions/navigation-landmark-restrictions.test.ts +0 -12
- package/aslint/app/rules/aslint/navigation-landmark-restrictions/navigation-landmark-restrictions.ts +0 -48
- package/aslint/app/rules/aslint/obsolete-html-attributes/obsolete-html-attributes.test.ts +0 -12
- package/aslint/app/rules/aslint/obsolete-html-attributes/obsolete-html-attributes.ts +0 -148
- package/aslint/app/rules/aslint/obsolete-html-elements/obsolete-html-elements.test.ts +0 -12
- package/aslint/app/rules/aslint/obsolete-html-elements/obsolete-html-elements.ts +0 -66
- package/aslint/app/rules/aslint/outline-zero/outline-zero.test.ts +0 -12
- package/aslint/app/rules/aslint/outline-zero/outline-zero.ts +0 -85
- package/aslint/app/rules/aslint/overlay/overlay.test.ts +0 -122
- package/aslint/app/rules/aslint/overlay/overlay.ts +0 -141
- package/aslint/app/rules/aslint/redundant/aria-role-dialog/aria-role-dialog.documentation.md +0 -49
- package/aslint/app/rules/aslint/redundant/aria-role-dialog/aria-role-dialog.test.ts +0 -91
- package/aslint/app/rules/aslint/redundant/aria-role-dialog/aria-role-dialog.ts +0 -62
- package/aslint/app/rules/aslint/redundant/capital-letters-words/capital-letters-words.documentation.md +0 -44
- package/aslint/app/rules/aslint/redundant/capital-letters-words/capital-letters-words.test.ts +0 -111
- package/aslint/app/rules/aslint/redundant/capital-letters-words/capital-letters-words.ts +0 -120
- package/aslint/app/rules/aslint/redundant/contentinfo-landmark-only-one/contentinfo-landmark-only-one.documentation.md +0 -45
- package/aslint/app/rules/aslint/redundant/contentinfo-landmark-only-one/contentinfo-landmark-only-one.test.ts +0 -63
- package/aslint/app/rules/aslint/redundant/contentinfo-landmark-only-one/contentinfo-landmark-only-one.ts +0 -44
- package/aslint/app/rules/aslint/redundant/empty-title-attribute/empty-title-attribute.documentation.md +0 -55
- package/aslint/app/rules/aslint/redundant/empty-title-attribute/empty-title-attribute.test.ts +0 -80
- package/aslint/app/rules/aslint/redundant/empty-title-attribute/empty-title-attribute.ts +0 -58
- package/aslint/app/rules/aslint/redundant/flash-content/flash-content.documentation.md +0 -48
- package/aslint/app/rules/aslint/redundant/flash-content/flash-content.test.ts +0 -52
- package/aslint/app/rules/aslint/redundant/flash-content/flash-content.ts +0 -32
- package/aslint/app/rules/aslint/redundant/font-style-italic/font-style-italic.documentation.md +0 -44
- package/aslint/app/rules/aslint/redundant/font-style-italic/font-style-italic.test.ts +0 -12
- package/aslint/app/rules/aslint/redundant/font-style-italic/font-style-italic.ts +0 -83
- package/aslint/app/rules/aslint/redundant/h1-must-be/h1-must-be.documentation.md +0 -46
- package/aslint/app/rules/aslint/redundant/h1-must-be/h1-must-be.test.ts +0 -46
- package/aslint/app/rules/aslint/redundant/h1-must-be/h1-must-be.ts +0 -36
- package/aslint/app/rules/aslint/role-application/role-application.test.ts +0 -48
- package/aslint/app/rules/aslint/role-application/role-application.ts +0 -38
- package/aslint/app/rules/aslint/rtl-content/rtl-content.test.ts +0 -12
- package/aslint/app/rules/aslint/rtl-content/rtl-content.ts +0 -75
- package/aslint/app/rules/aslint/unclear-uri-on-a/unclear-anchor-uri.test.ts +0 -12
- package/aslint/app/rules/aslint/unclear-uri-on-a/unclear-anchor-uri.ts +0 -48
- package/aslint/app/rules/aslint/unimportant/aria-hidden-false/aria-hidden-false.test.ts +0 -73
- package/aslint/app/rules/aslint/unimportant/aria-hidden-false/aria-hidden-false.ts +0 -34
- package/aslint/app/rules/aslint/unimportant/aria-hidden-false/aria-hidden.documentation.md +0 -32
- package/aslint/app/rules/aslint/unimportant/content-editable-missing-attributes/content-editable-missing-attributes.docmentation.md +0 -48
- package/aslint/app/rules/aslint/unimportant/content-editable-missing-attributes/content-editable-missing-attributes.test.ts +0 -67
- package/aslint/app/rules/aslint/unimportant/content-editable-missing-attributes/content-editable-missing-attributes.ts +0 -63
- package/aslint/app/rules/aslint/unsupported-role-on-element/unsupported-role-on-element.test.ts +0 -12
- package/aslint/app/rules/aslint/unsupported-role-on-element/unsupported-role-on-element.ts +0 -63
- package/aslint/app/rules/aslint/used/elements-not-allowed-in-head/elements-not-allowed-in-head.documentation.md +0 -65
- package/aslint/app/rules/aslint/used/elements-not-allowed-in-head/elements-not-allowed-in-head.test.ts +0 -53
- package/aslint/app/rules/aslint/used/elements-not-allowed-in-head/elements-not-allowed-in-head.ts +0 -47
- package/aslint/app/rules/aslint/used/headings-sibling-unique/headings-sibling-unique.documentation.md +0 -57
- package/aslint/app/rules/aslint/used/headings-sibling-unique/headings-sibling-unique.test.ts +0 -52
- package/aslint/app/rules/aslint/used/headings-sibling-unique/headings-sibling-unique.ts +0 -63
- package/aslint/app/rules/aslint/used/horizontal-rule/horizontal-rule.documentation.md +0 -39
- package/aslint/app/rules/aslint/used/horizontal-rule/horizontal-rule.test.ts +0 -66
- package/aslint/app/rules/aslint/used/horizontal-rule/horizontal-rule.ts +0 -37
- package/aslint/utils/aria.test.ts +0 -12
- package/aslint/utils/aria.ts +0 -120
- package/aslint/utils/async.test.ts +0 -25
- package/aslint/utils/async.ts +0 -22
- package/aslint/utils/common.test.ts +0 -239
- package/aslint/utils/common.ts +0 -168
- package/aslint/utils/console.test.ts +0 -85
- package/aslint/utils/console.ts +0 -89
- package/aslint/utils/css.test.ts +0 -153
- package/aslint/utils/css.ts +0 -191
- package/aslint/utils/dom.test.ts +0 -627
- package/aslint/utils/dom.ts +0 -1051
- package/aslint/utils/env.test.ts +0 -14
- package/aslint/utils/env.ts +0 -8
- package/aslint/utils/func.test.ts +0 -160
- package/aslint/utils/func.ts +0 -70
- package/aslint/utils/global.test.ts +0 -12
- package/aslint/utils/global.ts +0 -25
- package/aslint/utils/object.test.ts +0 -524
- package/aslint/utils/object.ts +0 -278
- package/aslint/utils/report.test.ts +0 -56
- package/aslint/utils/report.ts +0 -36
- package/aslint/utils/text.test.ts +0 -270
- package/aslint/utils/text.ts +0 -165
- package/aslint/utils/time.test.ts +0 -43
- package/aslint/utils/time.ts +0 -33
package/aslint/utils/object.ts
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { Func } from './func';
|
|
2
|
-
export class ObjectUtility {
|
|
3
|
-
private static reMethod: RegExp = /^(function|object)$/;
|
|
4
|
-
private static reUnknown: RegExp = /^unknown$/;
|
|
5
|
-
|
|
6
|
-
public static getTypeOf(obj?: any): string {
|
|
7
|
-
const defaultType = 'unknown';
|
|
8
|
-
|
|
9
|
-
if (arguments.length !== 1) {
|
|
10
|
-
return defaultType;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return Object.prototype.toString.call(obj).slice(8, -1)
|
|
14
|
-
.toLowerCase();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
* @method
|
|
19
|
-
* @param {String} type Type of object which you want to check
|
|
20
|
-
* @param {Object} obj Object to test
|
|
21
|
-
* @return {Boolean} Returns true if object type matched to required type
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
public static isTypeOf(obj: any, typeToCheck: string): boolean {
|
|
25
|
-
if (arguments.length < 2) {
|
|
26
|
-
throw new TypeError('[ObjectUtility.isTypeOf] requires two arguments');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const type: string = typeToCheck.toLowerCase();
|
|
30
|
-
|
|
31
|
-
return this.getTypeOf(obj) === type;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public static isNumber(value: any): boolean {
|
|
35
|
-
if (ObjectUtility.getTypeOf(value) === 'number') {
|
|
36
|
-
return Number.isFinite(value);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (ObjectUtility.getTypeOf(value) === 'string') {
|
|
40
|
-
return value.trim().length > 0 && Number.isFinite(Number(value));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public static isHtmlElement(el: HTMLElement | Element | Node | null): boolean {
|
|
47
|
-
if (el === null) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
return el instanceof Element || el instanceof HTMLDocument;
|
|
53
|
-
} catch (t) {
|
|
54
|
-
return (
|
|
55
|
-
typeof el === 'object' &&
|
|
56
|
-
el.nodeType === Node.ELEMENT_NODE &&
|
|
57
|
-
typeof (el as any).style === 'object' &&
|
|
58
|
-
typeof el.ownerDocument === 'object'
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public static isHostMethod(obj: any, method: string): boolean {
|
|
64
|
-
if (!obj) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const t: string = typeof obj[method];
|
|
69
|
-
|
|
70
|
-
return this.reUnknown.test(t) || (this.reMethod.test(t) && Boolean(obj)) || false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public static isHostObjectProperty(o: any, p: string): boolean {
|
|
74
|
-
const t: string = typeof o[p];
|
|
75
|
-
|
|
76
|
-
return Boolean(this.reMethod.test(t) && o[p]);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public static isRealObjectProperty(o: any, p: string): boolean {
|
|
80
|
-
return Boolean(typeof o[p] === 'object' && o[p]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public static deepMerge(source: any, target: any): any {
|
|
84
|
-
const mergeKeyValue = (key: string): void => {
|
|
85
|
-
if (source[key] instanceof Object && target[key] instanceof Object) {
|
|
86
|
-
if (Array.isArray(source[key]) && Array.isArray(target[key])) {
|
|
87
|
-
source[key] = Array.from(new Set(source[key].concat(target[key])));
|
|
88
|
-
} else if (Array.isArray(source[key]) === false && Array.isArray(target[key]) === false) {
|
|
89
|
-
this.deepMerge(source[key], target[key]);
|
|
90
|
-
} else {
|
|
91
|
-
source[key] = target[key];
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
source[key] = target[key];
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
Object.keys(target).forEach(mergeKeyValue);
|
|
99
|
-
|
|
100
|
-
return source;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public static extend(destination: any, source: any): any {
|
|
104
|
-
let property: any;
|
|
105
|
-
let src: any;
|
|
106
|
-
|
|
107
|
-
const cloneArray = (a: any): any => {
|
|
108
|
-
return Object.assign({}, a);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
for (property in source) {
|
|
112
|
-
if (Object.prototype.hasOwnProperty.call(source, property)) {
|
|
113
|
-
src = source[property];
|
|
114
|
-
|
|
115
|
-
if (this.isTypeOf(src, 'object')) {
|
|
116
|
-
destination[property] = destination[property] || {};
|
|
117
|
-
this.extend(destination[property], src);
|
|
118
|
-
} else if (Array.isArray(src)) {
|
|
119
|
-
destination[property] = src.map(cloneArray);
|
|
120
|
-
} else if (this.getTypeOf(src) === 'date') {
|
|
121
|
-
destination[property] = new Date(src.valueOf());
|
|
122
|
-
} else if (this.getTypeOf(src) === 'regexp') {
|
|
123
|
-
destination[property] = new RegExp(src);
|
|
124
|
-
} else {
|
|
125
|
-
destination[property] = source[property];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return destination;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/*
|
|
134
|
-
* Other objects can be added as well
|
|
135
|
-
* Other clones: https://github.com/pvorb/clone/blob/master/clone.js, https://github.com/angular/angular.js/blob/master/src/Angular.js#L453
|
|
136
|
-
*/
|
|
137
|
-
public static clone(o: any): any {
|
|
138
|
-
const gdcc: string = '__getDeepCircularCopy__';
|
|
139
|
-
|
|
140
|
-
let result: any;
|
|
141
|
-
|
|
142
|
-
if (o !== Object(o)) {
|
|
143
|
-
return o;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const set: boolean = gdcc in o;
|
|
147
|
-
const cache: any = o[gdcc];
|
|
148
|
-
|
|
149
|
-
if (set && typeof cache === 'function') {
|
|
150
|
-
return cache();
|
|
151
|
-
}
|
|
152
|
-
// else
|
|
153
|
-
o[gdcc] = function (): any {
|
|
154
|
-
return result;
|
|
155
|
-
}; // overwrite
|
|
156
|
-
|
|
157
|
-
if (Object.getPrototypeOf(o) === null) {
|
|
158
|
-
console.log(o);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (Array.isArray(o)) {
|
|
162
|
-
const cloneArray: any = (a: any): any => {
|
|
163
|
-
if (typeof a === 'object') {
|
|
164
|
-
if (a === null) {
|
|
165
|
-
return a;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return Object.assign({}, a);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return a;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
result = o.map(cloneArray);
|
|
175
|
-
} else if (Object.getPrototypeOf(o).constructor.name.toLowerCase() === 'date') {
|
|
176
|
-
return new Date(o.valueOf());
|
|
177
|
-
} else if (Object.getPrototypeOf(o).constructor.name.toLowerCase() === 'regexp') {
|
|
178
|
-
return new RegExp(o);
|
|
179
|
-
} else {
|
|
180
|
-
result = {};
|
|
181
|
-
for (const prop in o) {
|
|
182
|
-
if (prop !== gdcc) {
|
|
183
|
-
result[prop] = ObjectUtility.clone(o[prop]);
|
|
184
|
-
} else if (set) {
|
|
185
|
-
result[prop] = ObjectUtility.clone(cache);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (set) {
|
|
191
|
-
o[gdcc] = cache; // reset
|
|
192
|
-
} else {
|
|
193
|
-
delete o[gdcc]; // unset again
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
public static deleteProperties(obj: any): any {
|
|
200
|
-
let prop: any;
|
|
201
|
-
|
|
202
|
-
for (prop in obj) {
|
|
203
|
-
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
204
|
-
delete obj[prop];
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return obj;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
public static clearArray(arr: []): [] {
|
|
212
|
-
arr.length = 0;
|
|
213
|
-
|
|
214
|
-
return arr;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
public static isNativeMethod(m: any): boolean {
|
|
218
|
-
const re: RegExp = new RegExp('^(function|object)$', 'i');
|
|
219
|
-
const t: string = typeof m;
|
|
220
|
-
let s: string;
|
|
221
|
-
|
|
222
|
-
if (re.test(t)) {
|
|
223
|
-
// Returns a string representing the object and check for [native code] string
|
|
224
|
-
s = String(m);
|
|
225
|
-
|
|
226
|
-
return s.indexOf('[native code]') !== -1;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public static getProperty(objectItem: any, keyPath: string): any {
|
|
233
|
-
const properties: string[] = keyPath.split('.');
|
|
234
|
-
const len: number = properties.length;
|
|
235
|
-
let obj: any = objectItem;
|
|
236
|
-
|
|
237
|
-
for (let i: number = 0; i < len; i += 1) {
|
|
238
|
-
if (!obj || !obj.hasOwnProperty(properties[i])) {
|
|
239
|
-
return undefined;
|
|
240
|
-
}
|
|
241
|
-
obj = obj[properties[i]];
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return obj;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
public static setProperty(o: any, pathValue: string, value: any): any {
|
|
248
|
-
let obj: any = o;
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
this.isTypeOf(o, 'object') === false ||
|
|
252
|
-
(this.isTypeOf(o, 'array') === false && this.isTypeOf(pathValue, 'string') === false)
|
|
253
|
-
) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const path: string[] = pathValue.split('.');
|
|
258
|
-
const last: string | undefined = path.pop();
|
|
259
|
-
|
|
260
|
-
if (this.getProperty(o, pathValue) === undefined) {
|
|
261
|
-
Func.namespace(pathValue, o);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
while (path.length && obj) {
|
|
265
|
-
obj = obj[(path.shift()) as keyof typeof obj];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (typeof last === 'undefined') {
|
|
269
|
-
// eslint-disable-next-line consistent-return
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
obj[last] = value;
|
|
274
|
-
|
|
275
|
-
return obj[last];
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { $auditIssue, $severity } from '../constants/accessibility';
|
|
2
|
-
import { ReportUtility } from './report';
|
|
3
|
-
|
|
4
|
-
describe('ReportUtility', () => {
|
|
5
|
-
|
|
6
|
-
it('should indicate that class exists', () => {
|
|
7
|
-
const reportUtility = new ReportUtility();
|
|
8
|
-
|
|
9
|
-
expect(reportUtility).toBeDefined();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('#getRuleIssueTypeBySeverity', () => {
|
|
13
|
-
|
|
14
|
-
it('should return error for "critical", "high" and "low" severities', () => {
|
|
15
|
-
expect(ReportUtility.getRuleIssueTypeBySeverity($severity.critical)).toBe($auditIssue.error);
|
|
16
|
-
expect(ReportUtility.getRuleIssueTypeBySeverity($severity.critical)).toBe($auditIssue.error);
|
|
17
|
-
expect(ReportUtility.getRuleIssueTypeBySeverity($severity.critical)).toBe($auditIssue.error);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should return warning for "info" severity', () => {
|
|
21
|
-
expect(ReportUtility.getRuleIssueTypeBySeverity($severity.info)).toBe($auditIssue.warning);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should identify any other undetermined severity as no-issue i.e. "passed"', () => {
|
|
25
|
-
expect(ReportUtility.getRuleIssueTypeBySeverity('qwerty')).toBe($auditIssue.passed);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('#getScore', () => {
|
|
31
|
-
|
|
32
|
-
it('should return expected scores for different combinations of issues', () => {
|
|
33
|
-
expect(ReportUtility.getScore({} as any)).toBe(100);
|
|
34
|
-
|
|
35
|
-
expect(ReportUtility.getScore({
|
|
36
|
-
error: 0,
|
|
37
|
-
passed: 456,
|
|
38
|
-
warning: 123
|
|
39
|
-
})).toBe(97);
|
|
40
|
-
|
|
41
|
-
expect(ReportUtility.getScore({
|
|
42
|
-
error: 23,
|
|
43
|
-
passed: 76,
|
|
44
|
-
warning: 11
|
|
45
|
-
})).toBe(76);
|
|
46
|
-
|
|
47
|
-
expect(ReportUtility.getScore({
|
|
48
|
-
error: 33,
|
|
49
|
-
passed: 0,
|
|
50
|
-
warning: 55
|
|
51
|
-
})).toBe(0);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
});
|
package/aslint/utils/report.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { $auditIssue, $severity } from '../constants/accessibility';
|
|
2
|
-
export class ReportUtility {
|
|
3
|
-
|
|
4
|
-
public static getRuleIssueTypeBySeverity(severity: string): $auditIssue {
|
|
5
|
-
switch (severity) {
|
|
6
|
-
case $severity.critical:
|
|
7
|
-
return $auditIssue.error;
|
|
8
|
-
|
|
9
|
-
case $severity.high:
|
|
10
|
-
return $auditIssue.error;
|
|
11
|
-
|
|
12
|
-
case $severity.low:
|
|
13
|
-
return $auditIssue.error;
|
|
14
|
-
|
|
15
|
-
case $severity.info:
|
|
16
|
-
return $auditIssue.warning;
|
|
17
|
-
|
|
18
|
-
default:
|
|
19
|
-
return $auditIssue.passed;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public static getScore(issueCount: { error: number; warning: number; passed: number }): number {
|
|
24
|
-
const errors: number = issueCount.error + issueCount.warning / 10;
|
|
25
|
-
const total: number = issueCount.passed + errors;
|
|
26
|
-
|
|
27
|
-
let errorRatio: number = 0;
|
|
28
|
-
|
|
29
|
-
if (total > 0) {
|
|
30
|
-
errorRatio = errors / total;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return Math.round((1 - errorRatio) * 100);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { DomUtility } from './dom';
|
|
2
|
-
import { TextUtility } from './text';
|
|
3
|
-
|
|
4
|
-
describe('Utils', () => {
|
|
5
|
-
|
|
6
|
-
describe('TextUtility', () => {
|
|
7
|
-
|
|
8
|
-
it('should indicate that class exists', () => {
|
|
9
|
-
const textUtility = new TextUtility();
|
|
10
|
-
|
|
11
|
-
expect(textUtility).toBeDefined();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
describe('#truncateWords', () => {
|
|
15
|
-
|
|
16
|
-
it('should truncate words', () => {
|
|
17
|
-
const str: string = 'This is just a sample text',
|
|
18
|
-
strAfter: string = TextUtility.truncateWords(str, 1),
|
|
19
|
-
DOTS: number = 6;
|
|
20
|
-
|
|
21
|
-
expect(strAfter.length).toBe(4 + DOTS);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should not truncate words if there is only one word', () => {
|
|
25
|
-
const str: string = 'Thisisanexample',
|
|
26
|
-
strAfter: string = TextUtility.truncateWords(str, 1),
|
|
27
|
-
DOTS: number = 6;
|
|
28
|
-
|
|
29
|
-
expect(strAfter.length).toBe(9 + DOTS);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should truncate words to default amounts', () => {
|
|
33
|
-
const str: string = 'This is just a sample text. This is just a sample text. This is just a sample text. ' +
|
|
34
|
-
'This is just a sample text. This is just a sample text. ' +
|
|
35
|
-
'This is just a sample text. This is just a sample text.',
|
|
36
|
-
strAfter: string = TextUtility.truncateWords(str),
|
|
37
|
-
DOTS: number = 6;
|
|
38
|
-
|
|
39
|
-
expect(strAfter.length).toBe(55 + DOTS);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('#truncate', () => {
|
|
45
|
-
|
|
46
|
-
it('should truncate string to specified number of characters', () => {
|
|
47
|
-
const str: string = 'This is just a sample text',
|
|
48
|
-
strAfter: string = TextUtility.truncate(str, 5),
|
|
49
|
-
DOTS: number = 6;
|
|
50
|
-
|
|
51
|
-
expect(strAfter.length).toBe(5 + DOTS);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should truncate string to default number of characters', () => {
|
|
55
|
-
const str = 'This is just a sample text. This is just a sample text. ' +
|
|
56
|
-
'This is just a sample text. This is just a sample text. ' +
|
|
57
|
-
'This is just a sample text. This is just a sample text. This is just a sample text.',
|
|
58
|
-
strAfter: string = TextUtility.truncate(str),
|
|
59
|
-
DOTS: number = 6;
|
|
60
|
-
|
|
61
|
-
expect(strAfter.length).toBe(50 + DOTS);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('#truncateInTheMiddle', () => {
|
|
67
|
-
|
|
68
|
-
it('should truncate middle content using default parameters', () => {
|
|
69
|
-
const str: string = 'Dinosaurs are a diverse group of reptiles of the clade Dinosauria ' +
|
|
70
|
-
'that first appeared during the Triassic. Although the exact origin and timing of the ' +
|
|
71
|
-
'evolution of dinosaurs is the subject of active research,[1] the current scientific ' +
|
|
72
|
-
'consensus places their origin between 231 and 243 million years ago.[2] ' +
|
|
73
|
-
'They became the dominant terrestrial vertebrates after the Triassic–Jurassic ' +
|
|
74
|
-
'extinction event 201 million years ago. Their dominance continued through the ' +
|
|
75
|
-
'Jurassic and Cretaceous periods and ended when the Cretaceous–Paleogene extinction ' +
|
|
76
|
-
'event led to the extinction of most dinosaur groups 66 million years ago.';
|
|
77
|
-
|
|
78
|
-
expect(TextUtility.truncateInTheMiddle(str)).toBe('Dinosaurs are a diverse group of reptiles of the clade Dinosauria that [...] nt led to the extinction of most dinosaur groups 66 million years ago.');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should truncate middle content using custom parameters', () => {
|
|
82
|
-
const str: string = 'Dinosaurs are a diverse group of reptiles of the clade Dinosauria that first appeared ' +
|
|
83
|
-
'during the Triassic. Although the exact origin and timing of the evolution of dinosaurs is the ' +
|
|
84
|
-
'subject of active research,[1] the current scientific consensus places their origin between 231 ' +
|
|
85
|
-
'and 243 million years ago.[2] They became the dominant terrestrial vertebrates after the Triassic–Jurassic ' +
|
|
86
|
-
'extinction event 201 million years ago. Their dominance continued through the Jurassic and Cretaceous ' +
|
|
87
|
-
'periods and ended when the Cretaceous–Paleogene extinction event led to the extinction of most ' +
|
|
88
|
-
'dinosaur groups 66 million years ago.';
|
|
89
|
-
|
|
90
|
-
expect(TextUtility.truncateInTheMiddle(str, 5, 5, 30)).toBe('Dinos [...] ago.');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should truncate middle node outerHTML content using default parameters', () => {
|
|
94
|
-
const node = document.createElement('area');
|
|
95
|
-
|
|
96
|
-
node.coords = '0,0,82,126';
|
|
97
|
-
node.href = 'sun.htm';
|
|
98
|
-
node.shape = 'rect';
|
|
99
|
-
|
|
100
|
-
document.documentElement.appendChild(node);
|
|
101
|
-
|
|
102
|
-
expect(TextUtility.truncateInTheMiddle(DomUtility.getNodeHTML(node)))
|
|
103
|
-
.toBe('<area coords="0,0,82,126" href="sun.htm" shape="rect">');
|
|
104
|
-
|
|
105
|
-
node.remove();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const text = 'Florence Cathedral, formally the Cattedrale di Santa Maria del Fiore, is a basilica in Florence, Italy. It was begun in 1296 in the Gothic style to a design of Arnolfo di Cambio, and was structurally completed by 1436, with the dome designed by Filippo Brunelleschi. The exterior of the cathedral is faced with polychrome marble panels in various shades of green and pink, bordered by white, and has an elaborate 19th-century Gothic Revival facade by Emilio De Fabris.';
|
|
109
|
-
|
|
110
|
-
it('should return truncated in the middle text with default parameters', () => {
|
|
111
|
-
expect(TextUtility.truncateInTheMiddle(text)).toEqual('Florence Cathedral, formally the Cattedrale di Santa Maria del Fiore, [...] s an elaborate 19th-century Gothic Revival facade by Emilio De Fabris.');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should return truncated in the middle text with 5 chars at the start', () => {
|
|
115
|
-
expect(TextUtility.truncateInTheMiddle(text, 5)).toEqual('Flore [...] s an elaborate 19th-century Gothic Revival facade by Emilio De Fabris.');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should return truncated in the middle text with 5 chars at the end', () => {
|
|
119
|
-
expect(TextUtility.truncateInTheMiddle(text, 0, 5)).toEqual('Florence Cathedral, formally the Cattedrale di Santa Maria del Fiore, [...] bris.');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should return truncated in the middle text with 5 chars in the end and maxLength parameter higher than text length', () => {
|
|
123
|
-
expect(TextUtility.truncateInTheMiddle(text, 0, 5, 10)).toEqual('Florence Cathedral, formally the Cattedrale di Santa Maria del Fiore, [...] bris.');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('should return truncated in the middle text with 5 chars in the end and maxLength parameter lower than text length', () => {
|
|
127
|
-
expect(TextUtility.truncateInTheMiddle('shorttext', 0, 5, 10)).toEqual('shorttext');
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('should return truncated in the middle text with 5 chars in the end and maxLength parameter lower than text length after trim', () => {
|
|
131
|
-
expect(TextUtility.truncateInTheMiddle(' shorttext. \n\r', 0, 5, 10)).toEqual(' shorttext. \n\r');
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should return truncated in the middle text with 20 chars at start, 99 chars at end, 33 maximum length', () => {
|
|
135
|
-
expect(TextUtility.truncateInTheMiddle(text, 20, 99, 33)).toEqual('Florence Cathedral, [...] nk, bordered by white, and has an elaborate 19th-century Gothic Revival facade by Emilio De Fabris.');
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
describe('#containsOnlyWhiteSpaces', () => {
|
|
140
|
-
|
|
141
|
-
it('should determine that the given string contains only white spaces', () => {
|
|
142
|
-
expect(TextUtility.containsOnlyWhiteSpaces('\t\r\n\v\f')).toBe(true);
|
|
143
|
-
expect(TextUtility.containsOnlyWhiteSpaces('')).toBe(true);
|
|
144
|
-
expect(TextUtility.containsOnlyWhiteSpaces(' ')).toBe(true);
|
|
145
|
-
expect(TextUtility.containsOnlyWhiteSpaces('\n')).toBe(true);
|
|
146
|
-
expect(TextUtility.containsOnlyWhiteSpaces('\r ')).toBe(true);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should determine that the given string contains not only white spaces', () => {
|
|
150
|
-
expect(TextUtility.containsOnlyWhiteSpaces(' s ')).toBe(false);
|
|
151
|
-
expect(TextUtility.containsOnlyWhiteSpaces(' a')).toBe(false);
|
|
152
|
-
expect(TextUtility.containsOnlyWhiteSpaces('1 ')).toBe(false);
|
|
153
|
-
expect(TextUtility.containsOnlyWhiteSpaces('hello')).toBe(false);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('#containsSpaceCharacter', () => {
|
|
158
|
-
|
|
159
|
-
it('should determine that the given string contains space character', () => {
|
|
160
|
-
expect(TextUtility.containsSpaceCharacter(' \t\n\f\r')).toBe(true);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe('#safeTrim', () => {
|
|
166
|
-
it('should trim all known whitespaces', () => {
|
|
167
|
-
expect(TextUtility.safeTrim('\t\r\n\v\f\u200B\u200C\u200D\u200E\u200F\u000b\u2028\u2029\uFEFF\u202D\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000').length).toBe(0);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
describe('#normalizeWhitespaces', () => {
|
|
172
|
-
it('should replace all new lines with a single white space', () => {
|
|
173
|
-
expect(TextUtility.normalizeWhitespaces('click\nhere')).toBe('click here');
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should replace all known whitespaces with a single white space', () => {
|
|
177
|
-
expect(TextUtility.normalizeWhitespaces(`click\t\r\n\v\f\u200B\u200C\u200D\u200E\u200F\u000b\u2028\u2029\uFEFF\u202D\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000here`)).toBe('click here');
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('should replace zero width space with regular space', () => {
|
|
181
|
-
const zeroWidthSpace: string = String.fromCharCode(8203);
|
|
182
|
-
|
|
183
|
-
expect(TextUtility.normalizeWhitespaces(`click${zeroWidthSpace}here`)).toBe('click here');
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe('#isUpperCase', () => {
|
|
188
|
-
|
|
189
|
-
it('should return true for string with capital letters only', () => {
|
|
190
|
-
expect(TextUtility.isUpperCase('TEST')).toBeTruthy();
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('should return false for string with mixed with capital and lower letters', () => {
|
|
194
|
-
const str: string = 'TEst';
|
|
195
|
-
|
|
196
|
-
expect(TextUtility.isUpperCase(str)).toBeFalsy();
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('should return false for string that contains non-letters and non-numbers only', () => {
|
|
200
|
-
const exampleString: Array<number> = [124, 160, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 160, 124];
|
|
201
|
-
let str: string = '';
|
|
202
|
-
let i: number;
|
|
203
|
-
|
|
204
|
-
for (i = 0; i < exampleString.length; i += 1) {
|
|
205
|
-
str += String.fromCharCode(exampleString[i]);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
expect(TextUtility.isUpperCase(str)).toBeFalsy();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
describe('#escape', () => {
|
|
214
|
-
const expectedText: string = '<a href="#">test&test'</a>';
|
|
215
|
-
|
|
216
|
-
it('escapes &<>"\'/', () => {
|
|
217
|
-
expect(TextUtility.escape('<a href="#">test&test\'</a>')).toBe(expectedText);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('should return string with escaped characters', (): void => {
|
|
221
|
-
expect(TextUtility.escape('&<>"/`=')).toBe('&<>"/`=');
|
|
222
|
-
expect(TextUtility.escape('test@#$%^*()_-+~\\|}{][;:?.,')).toBe('test@#$%^*()_-+~\\|}{][;:?.,');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
describe('#convertUnderscoresToDashes', () => {
|
|
228
|
-
|
|
229
|
-
it('should convert all underscores to dashes for provided string', () => {
|
|
230
|
-
expect(TextUtility.convertUnderscoresToDashes('this_is_an_example')).toBe('this-is-an-example');
|
|
231
|
-
expect(TextUtility.convertUnderscoresToDashes('this-is_an*example')).toBe('this-is-an*example');
|
|
232
|
-
expect(TextUtility.convertUnderscoresToDashes('this-is_an__example')).toBe('this-is-an--example');
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
describe('#convertDashesToUnderscores', () => {
|
|
238
|
-
|
|
239
|
-
it('should convert all dashes to underscores for provided string', () => {
|
|
240
|
-
expect(TextUtility.convertDashesToUnderscores('this-is-an-example')).toBe('this_is_an_example');
|
|
241
|
-
expect(TextUtility.convertDashesToUnderscores('this-is-an*example')).toBe('this_is_an*example');
|
|
242
|
-
expect(TextUtility.convertDashesToUnderscores('this-is-an--example')).toBe('this_is_an__example');
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
describe('#replacePlaceholder', () => {
|
|
248
|
-
it('should replace with default placeholder', () => {
|
|
249
|
-
expect(TextUtility.replacePlaceholder('ab=%0, c=%1', ['1', '2'])).toEqual('ab=1, c=2');
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('should replace with custom placeholder', () => {
|
|
253
|
-
expect(TextUtility.replacePlaceholder('ab=$0, c=$1', ['1', '2'], '$')).toEqual('ab=1, c=2');
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
describe('#areStringsTheSame', () => {
|
|
259
|
-
it('should determine that given 2 strings are the same', () => {
|
|
260
|
-
expect(TextUtility.areStringsTheSame('a', 'a')).toBeTruthy();
|
|
261
|
-
expect(TextUtility.areStringsTheSame('EXAMPLE', 'example')).toBeTruthy();
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('should determine that given 2 strings are not the same', () => {
|
|
265
|
-
expect(TextUtility.areStringsTheSame('a', 'á')).toBeFalsy();
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
});
|
|
270
|
-
});
|