testaro 18.2.0 → 18.4.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/aslint/utils/aria.test.ts +12 -0
- package/aslint/utils/aria.ts +120 -0
- package/aslint/utils/async.test.ts +25 -0
- package/aslint/utils/async.ts +22 -0
- package/aslint/utils/common.test.ts +239 -0
- package/aslint/utils/common.ts +168 -0
- package/aslint/utils/console.test.ts +85 -0
- package/aslint/utils/console.ts +89 -0
- package/aslint/utils/css.test.ts +153 -0
- package/aslint/utils/css.ts +191 -0
- package/aslint/utils/dom.test.ts +627 -0
- package/aslint/utils/dom.ts +1051 -0
- package/aslint/utils/env.test.ts +14 -0
- package/aslint/utils/env.ts +8 -0
- package/aslint/utils/func.test.ts +160 -0
- package/aslint/utils/func.ts +70 -0
- package/aslint/utils/global.test.ts +12 -0
- package/aslint/utils/global.ts +25 -0
- package/aslint/utils/object.test.ts +524 -0
- package/aslint/utils/object.ts +278 -0
- package/aslint/utils/report.test.ts +56 -0
- package/aslint/utils/report.ts +36 -0
- package/aslint/utils/text.test.ts +270 -0
- package/aslint/utils/text.ts +165 -0
- package/aslint/utils/time.test.ts +43 -0
- package/aslint/utils/time.ts +33 -0
- package/package.json +1 -1
- package/procs/getSource.js +35 -0
- package/testaro/dupAtt.js +86 -108
- package/testaro/headEl.js +83 -0
- package/testaro/hrRisk.js +67 -0
- package/tests/testaro.js +2 -0
- package/validation/tests/jobs/headEl.json +67 -0
- package/validation/tests/jobs/hrRisk.json +134 -0
- package/validation/tests/targets/headEl/index.html +16 -0
- package/validation/tests/targets/hrRisk/index.html +18 -0
- /package/aslint/app/rules/aslint/{aria-role-dialog → redundant/aria-role-dialog}/aria-role-dialog.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{aria-role-dialog → redundant/aria-role-dialog}/aria-role-dialog.test.ts +0 -0
- /package/aslint/app/rules/aslint/{aria-role-dialog → redundant/aria-role-dialog}/aria-role-dialog.ts +0 -0
- /package/aslint/app/rules/aslint/{capital-letters-words → redundant/capital-letters-words}/capital-letters-words.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{capital-letters-words → redundant/capital-letters-words}/capital-letters-words.test.ts +0 -0
- /package/aslint/app/rules/aslint/{capital-letters-words → redundant/capital-letters-words}/capital-letters-words.ts +0 -0
- /package/aslint/app/rules/aslint/{contentinfo-landmark-only-one → redundant/contentinfo-landmark-only-one}/contentinfo-landmark-only-one.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{contentinfo-landmark-only-one → redundant/contentinfo-landmark-only-one}/contentinfo-landmark-only-one.test.ts +0 -0
- /package/aslint/app/rules/aslint/{contentinfo-landmark-only-one → redundant/contentinfo-landmark-only-one}/contentinfo-landmark-only-one.ts +0 -0
- /package/aslint/app/rules/aslint/{empty-title-attribute → redundant/empty-title-attribute}/empty-title-attribute.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{empty-title-attribute → redundant/empty-title-attribute}/empty-title-attribute.test.ts +0 -0
- /package/aslint/app/rules/aslint/{empty-title-attribute → redundant/empty-title-attribute}/empty-title-attribute.ts +0 -0
- /package/aslint/app/rules/aslint/{flash-content → redundant/flash-content}/flash-content.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{flash-content → redundant/flash-content}/flash-content.test.ts +0 -0
- /package/aslint/app/rules/aslint/{flash-content → redundant/flash-content}/flash-content.ts +0 -0
- /package/aslint/app/rules/aslint/{font-style-italic → redundant/font-style-italic}/font-style-italic.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{font-style-italic → redundant/font-style-italic}/font-style-italic.test.ts +0 -0
- /package/aslint/app/rules/aslint/{font-style-italic → redundant/font-style-italic}/font-style-italic.ts +0 -0
- /package/aslint/app/rules/aslint/{h1-must-be → redundant/h1-must-be}/h1-must-be.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{h1-must-be → redundant/h1-must-be}/h1-must-be.test.ts +0 -0
- /package/aslint/app/rules/aslint/{h1-must-be → redundant/h1-must-be}/h1-must-be.ts +0 -0
- /package/aslint/app/rules/aslint/{aria-hidden-false → unimportant/aria-hidden-false}/aria-hidden-false.test.ts +0 -0
- /package/aslint/app/rules/aslint/{aria-hidden-false → unimportant/aria-hidden-false}/aria-hidden-false.ts +0 -0
- /package/aslint/app/rules/aslint/{aria-hidden-false → unimportant/aria-hidden-false}/aria-hidden.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{content-editable-missing-attributes → unimportant/content-editable-missing-attributes}/content-editable-missing-attributes.docmentation.md +0 -0
- /package/aslint/app/rules/aslint/{content-editable-missing-attributes → unimportant/content-editable-missing-attributes}/content-editable-missing-attributes.test.ts +0 -0
- /package/aslint/app/rules/aslint/{content-editable-missing-attributes → unimportant/content-editable-missing-attributes}/content-editable-missing-attributes.ts +0 -0
- /package/aslint/app/rules/aslint/{elements-not-allowed-in-head → used/elements-not-allowed-in-head}/elements-not-allowed-in-head.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{elements-not-allowed-in-head → used/elements-not-allowed-in-head}/elements-not-allowed-in-head.test.ts +0 -0
- /package/aslint/app/rules/aslint/{elements-not-allowed-in-head → used/elements-not-allowed-in-head}/elements-not-allowed-in-head.ts +0 -0
- /package/aslint/app/rules/aslint/{headings-sibling-unique → used/headings-sibling-unique}/headings-sibling-unique.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{headings-sibling-unique → used/headings-sibling-unique}/headings-sibling-unique.test.ts +0 -0
- /package/aslint/app/rules/aslint/{headings-sibling-unique → used/headings-sibling-unique}/headings-sibling-unique.ts +0 -0
- /package/aslint/app/rules/aslint/{horizontal-rule → used/horizontal-rule}/horizontal-rule.documentation.md +0 -0
- /package/aslint/app/rules/aslint/{horizontal-rule → used/horizontal-rule}/horizontal-rule.test.ts +0 -0
- /package/aslint/app/rules/aslint/{horizontal-rule → used/horizontal-rule}/horizontal-rule.ts +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Global } from './global';
|
|
2
|
+
import { Func } from './func';
|
|
3
|
+
|
|
4
|
+
describe('Func', () => {
|
|
5
|
+
|
|
6
|
+
describe('#extend', () => {
|
|
7
|
+
let objectToExtend: { defaultProperty?: any; defaultMethod?: any; o?: any },
|
|
8
|
+
objectExtendDefault: { defaultProperty: number; defaultMethod: () => any },
|
|
9
|
+
objectExtendDeep: { defaultProperty: number; defaultMethod: () => any; o: { arr: any[] } };
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
objectToExtend = {};
|
|
13
|
+
|
|
14
|
+
objectExtendDefault = {
|
|
15
|
+
defaultMethod: () => {
|
|
16
|
+
return null;
|
|
17
|
+
},
|
|
18
|
+
defaultProperty: 1
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
objectExtendDeep = {
|
|
22
|
+
defaultMethod: () => {
|
|
23
|
+
return null;
|
|
24
|
+
},
|
|
25
|
+
defaultProperty: 1,
|
|
26
|
+
o: {
|
|
27
|
+
arr: []
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('extend empty object with default values', () => {
|
|
33
|
+
Func.mixin(objectToExtend, objectExtendDefault);
|
|
34
|
+
expect(objectToExtend.defaultProperty).toBe(1);
|
|
35
|
+
expect(typeof objectToExtend.defaultMethod).toBe('function');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('extend filled object with default values, overwrite values', () => {
|
|
39
|
+
objectToExtend.defaultProperty = 2;
|
|
40
|
+
Func.mixin(objectToExtend, objectExtendDefault);
|
|
41
|
+
expect(objectToExtend.defaultProperty).toBe(1);
|
|
42
|
+
expect(typeof objectToExtend.defaultMethod).toBe('function');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('deep extend filled object with default values, overwrite values', () => {
|
|
46
|
+
Func.mixin(objectToExtend, objectExtendDeep);
|
|
47
|
+
expect(objectToExtend.defaultProperty).toBe(1);
|
|
48
|
+
expect(typeof objectToExtend.defaultMethod).toBe('function');
|
|
49
|
+
expect(typeof objectToExtend.o).toBe('object');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('#defaults', () => {
|
|
55
|
+
|
|
56
|
+
let target: { str: any; num: any; bool: any; arr: any; obj: any; und: any; nul: any; a?: any; zero?: any };
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
target = {
|
|
60
|
+
arr: [1, 2, 3],
|
|
61
|
+
bool: true,
|
|
62
|
+
nul: null,
|
|
63
|
+
num: 42,
|
|
64
|
+
obj: {
|
|
65
|
+
bar: 'bar',
|
|
66
|
+
foo: 'foo'
|
|
67
|
+
},
|
|
68
|
+
str: 'str',
|
|
69
|
+
und: undefined
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
afterEach(() => {
|
|
74
|
+
target = undefined;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('add properties to the target object if the property is not previously defined', () => {
|
|
78
|
+
Func.defaults(target, {
|
|
79
|
+
a: 'a',
|
|
80
|
+
und: 'defined',
|
|
81
|
+
zero: 0
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(target.str).toBe('str');
|
|
85
|
+
expect(target.num).toBe(42);
|
|
86
|
+
expect(target.bool).toBe(true);
|
|
87
|
+
expect(target.arr).toEqual([1, 2, 3]);
|
|
88
|
+
expect(target.obj).toEqual({
|
|
89
|
+
bar: 'bar',
|
|
90
|
+
foo: 'foo'
|
|
91
|
+
});
|
|
92
|
+
expect(target.und).toBe('defined');
|
|
93
|
+
expect(target.nul).toBe(null);
|
|
94
|
+
expect(target.a).toBe('a');
|
|
95
|
+
expect(target.zero).toBe(0);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('does not add a property to the target object if it is already defined', () => {
|
|
99
|
+
Func.defaults(target, {
|
|
100
|
+
nul: 'null',
|
|
101
|
+
str: 'newstr',
|
|
102
|
+
und: 'defined'
|
|
103
|
+
});
|
|
104
|
+
expect(target.str).toBe('str');
|
|
105
|
+
expect(target.nul).toBe(null);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('returns a new object with all merged defaults if target is null or undefined', () => {
|
|
109
|
+
const defaulted = Func.defaults(null, {
|
|
110
|
+
a: 'a',
|
|
111
|
+
zero: 0
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(defaulted).toEqual({
|
|
115
|
+
a: 'a',
|
|
116
|
+
zero: 0
|
|
117
|
+
});
|
|
118
|
+
expect(defaulted).not.toBe({
|
|
119
|
+
a: 'a',
|
|
120
|
+
zero: 0
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('#namespace', () => {
|
|
126
|
+
const ns = 'Test.Foo.Bar.Baz';
|
|
127
|
+
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
expect(Global.context.Test).toBeUndefined();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
afterEach(() => {
|
|
133
|
+
delete Global.context.Test;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('returns the global object if it exists for the given namespace', () => {
|
|
137
|
+
Global.context.Test = {
|
|
138
|
+
Already: 'here'
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const baz = Func.namespace(ns);
|
|
142
|
+
|
|
143
|
+
expect(Global.context.Test).toBeDefined();
|
|
144
|
+
expect(Global.context.Test.Already).toBe('here');
|
|
145
|
+
expect(Global.context.Test.Foo.Bar).toBeDefined();
|
|
146
|
+
expect(Global.context.Test.Foo.Bar.Baz).toBeDefined();
|
|
147
|
+
expect(Global.context.Test.Foo.Bar.Baz).toBe(baz);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('returns a new object if no global object exists for the given namespace', () => {
|
|
151
|
+
const baz = Func.namespace(ns);
|
|
152
|
+
|
|
153
|
+
expect(Global.context.Test.Foo).toBeDefined();
|
|
154
|
+
expect(Global.context.Test.Foo.Bar).toBeDefined();
|
|
155
|
+
expect(Global.context.Test.Foo.Bar.Baz).toBeDefined();
|
|
156
|
+
expect(Global.context.Test.Foo.Bar.Baz).toBe(baz);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export class Func {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deep object mixin, extending destination object with properties of source object
|
|
5
|
+
* @method
|
|
6
|
+
* @param {Object} destination object with original values/ new object
|
|
7
|
+
* @param {Object} source object with default values
|
|
8
|
+
* @return {Object} extended object
|
|
9
|
+
*/
|
|
10
|
+
public static mixin(targetObject: any, ...sources: any[]): any {
|
|
11
|
+
const target: any = targetObject ? targetObject : {};
|
|
12
|
+
|
|
13
|
+
const processSources = (src: any): any => {
|
|
14
|
+
if (src) {
|
|
15
|
+
const copyValue = (key: string): any => {
|
|
16
|
+
target[key] = src[key];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
Object.keys(src).forEach(copyValue);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
sources.forEach(processSources);
|
|
24
|
+
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* similar to mixin, but only adds to the target the properties which are undefined
|
|
30
|
+
* @param {object} targetObject - the object to extend
|
|
31
|
+
* @param {...object} sources - an object(s) with properties to be added to the target if the property doesn't exist on the target or on a previous source
|
|
32
|
+
* @returns {object} modified target with added defaults
|
|
33
|
+
*/
|
|
34
|
+
public static defaults(targetObject: any, sources: any): any {
|
|
35
|
+
let target: any = {};
|
|
36
|
+
|
|
37
|
+
if (targetObject) {
|
|
38
|
+
target = targetObject;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (sources) {
|
|
42
|
+
const processSrc = (key: string): void => {
|
|
43
|
+
if (typeof target[key] === 'undefined') {
|
|
44
|
+
target[key] = sources[key];
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Object.keys(sources).forEach(processSrc);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static namespace(namespace: any, context?: any): any {
|
|
55
|
+
const parts: string[] = namespace.split('.');
|
|
56
|
+
const len: number = parts.length;
|
|
57
|
+
let parent: any = context || global;
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < len; i += 1) {
|
|
60
|
+
if (parent[parts[i]] === undefined) {
|
|
61
|
+
parent[parts[i]] = {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
parent = parent[parts[i]];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return parent;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export class Global {
|
|
3
|
+
|
|
4
|
+
public static get context(): any {
|
|
5
|
+
return (function (): any {
|
|
6
|
+
if (typeof globalThis === 'object') {
|
|
7
|
+
return globalThis;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(Object.prototype, '__magic__', {
|
|
11
|
+
configurable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/* @ts-ignore */
|
|
18
|
+
__magic__.globalThis = __magic__;
|
|
19
|
+
|
|
20
|
+
/* @ts-ignore */
|
|
21
|
+
delete Object.prototype.__magic__;
|
|
22
|
+
}());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|