@testgorilla/tgo-typing-test 0.0.1 → 2.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/.eslintrc.json +2 -1
- package/package.json +5 -9
- package/src/lib/components/tgo-typing-replay-input/tgo-typing-replay-input.component.ts +6 -7
- package/src/lib/components/tgo-typing-test/tgo-typing-test.component.ts +36 -43
- package/src/lib/helpers/test/test-logic.ts +18 -18
- package/src/test-setup.ts +19 -0
package/.eslintrc.json
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testgorilla/tgo-typing-test",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "~
|
|
6
|
-
"@angular/core": "~
|
|
7
|
-
"@angular/animations": "~
|
|
8
|
-
"jest-preset-angular": "
|
|
5
|
+
"@angular/common": "~19.2.17",
|
|
6
|
+
"@angular/core": "~19.2.17",
|
|
7
|
+
"@angular/animations": "~19.2.17",
|
|
8
|
+
"jest-preset-angular": "14.4.2",
|
|
9
9
|
"rxjs": "~7.8.1"
|
|
10
10
|
},
|
|
11
11
|
"typings": "src/lib/types",
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"license": "PROPRIETARY",
|
|
14
|
-
"publishConfig": {
|
|
15
|
-
"access": "restricted",
|
|
16
|
-
"registry": "https://registry.npmjs.org/"
|
|
17
|
-
},
|
|
18
14
|
"displayName": "Typing Test",
|
|
19
15
|
"description": "Typing Test component"
|
|
20
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
|
1
|
+
import { AfterViewInit, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
|
2
2
|
import { setFunbox } from '../../helpers/config';
|
|
3
3
|
import {
|
|
4
4
|
initializeReplayPrompt,
|
|
@@ -13,13 +13,12 @@ import {
|
|
|
13
13
|
import { CommonModule } from '@angular/common';
|
|
14
14
|
|
|
15
15
|
@Component({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
styleUrls: ['../../styles/index.scss'],
|
|
16
|
+
selector: 'tgo-typing-replay-input',
|
|
17
|
+
imports: [CommonModule],
|
|
18
|
+
templateUrl: './tgo-typing-replay-input.component.html',
|
|
19
|
+
styleUrls: ['../../styles/index.scss']
|
|
21
20
|
})
|
|
22
|
-
export class TgoTypingReplayInputComponent implements OnInit {
|
|
21
|
+
export class TgoTypingReplayInputComponent implements OnInit, AfterViewInit {
|
|
23
22
|
@Input() replayExport: any;
|
|
24
23
|
@Input() funbox = 'none';
|
|
25
24
|
replayExportData: any;
|
|
@@ -57,49 +57,42 @@ import { disableCheckIfTimeIsUp } from '../../helpers/test/test-timer';
|
|
|
57
57
|
import { CommonModule } from '@angular/common';
|
|
58
58
|
|
|
59
59
|
@Component({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
animate('100ms')
|
|
97
|
-
]),
|
|
98
|
-
transition('false => true', [
|
|
99
|
-
animate('100ms')
|
|
100
|
-
])
|
|
101
|
-
])
|
|
102
|
-
]
|
|
60
|
+
selector: 'tgo-typing-test',
|
|
61
|
+
imports: [CommonModule],
|
|
62
|
+
templateUrl: './tgo-typing-test.component.html',
|
|
63
|
+
styleUrl: '../../styles/index.scss',
|
|
64
|
+
animations: [
|
|
65
|
+
trigger('fadeIn', [
|
|
66
|
+
state('show', style({ opacity: 1 })),
|
|
67
|
+
state('hide', style({ opacity: 0 })),
|
|
68
|
+
transition('show => hide', [
|
|
69
|
+
animate('125ms')
|
|
70
|
+
]),
|
|
71
|
+
transition('hide => show', [
|
|
72
|
+
animate('125ms')
|
|
73
|
+
])
|
|
74
|
+
]),
|
|
75
|
+
trigger('updatePositionCaret', [
|
|
76
|
+
state('true', style({
|
|
77
|
+
top: '{{caretTopPos}}px',
|
|
78
|
+
left: '{{caretLeftPos}}px'
|
|
79
|
+
}), {
|
|
80
|
+
params: { caretTopPos: 0, caretLeftPos: 0 }
|
|
81
|
+
}),
|
|
82
|
+
state('false', style({
|
|
83
|
+
top: '{{caretTopPos}}px',
|
|
84
|
+
left: '{{caretLeftPos}}px'
|
|
85
|
+
}), {
|
|
86
|
+
params: { caretTopPos: 0, caretLeftPos: 0 }
|
|
87
|
+
}),
|
|
88
|
+
transition('true => false', [
|
|
89
|
+
animate('100ms')
|
|
90
|
+
]),
|
|
91
|
+
transition('false => true', [
|
|
92
|
+
animate('100ms')
|
|
93
|
+
])
|
|
94
|
+
])
|
|
95
|
+
]
|
|
103
96
|
})
|
|
104
97
|
export class TgoTypingTestComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy {
|
|
105
98
|
showCaps$: BehaviorSubject<boolean>;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
1
2
|
import Config from '../../helpers/config';
|
|
2
|
-
import
|
|
3
|
+
import { MonkeyTypes } from '../../types/types';
|
|
3
4
|
import * as Misc from '../../utils/misc';
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
5
|
+
import QuotesController from '../controllers/quotes-controller';
|
|
6
|
+
import * as TimerEvent from '../observables/timer-event';
|
|
7
|
+
import * as ActivePage from '../states/active-page';
|
|
8
|
+
import * as PageTransition from '../states/page-transition';
|
|
9
|
+
import * as TestActive from '../states/test-active';
|
|
10
|
+
import * as Caret from './caret';
|
|
6
11
|
import * as CustomText from './custom-text';
|
|
7
|
-
import * as
|
|
12
|
+
import * as EnglishPunctuation from './english-punctuation';
|
|
8
13
|
import * as Focus from './focus';
|
|
9
|
-
import * as
|
|
10
|
-
import * as TimerProgress from './timer-progress';
|
|
14
|
+
import * as ManualRestart from './manual-restart-tracker';
|
|
11
15
|
import * as OutOfFocus from './out-of-focus';
|
|
12
|
-
import * as TestTimer from './test-timer';
|
|
13
16
|
import * as Replay from './replay';
|
|
14
|
-
import * as WeakSpot from './weak-spot';
|
|
15
|
-
import * as Wordset from './wordset';
|
|
16
|
-
import * as EnglishPunctuation from './english-punctuation';
|
|
17
|
-
import * as ActivePage from '../states/active-page';
|
|
18
|
-
import * as TestActive from '../states/test-active';
|
|
19
17
|
import * as TestInput from './test-input';
|
|
20
18
|
import * as TestState from './test-state';
|
|
19
|
+
import * as TestStats from './test-stats';
|
|
20
|
+
import * as TestTimer from './test-timer';
|
|
21
|
+
import * as TestUI from './test-ui';
|
|
21
22
|
import * as TestWords from './test-words';
|
|
22
|
-
import * as
|
|
23
|
-
import
|
|
24
|
-
import * as
|
|
25
|
-
import { MonkeyTypes } from '../../types/types';
|
|
23
|
+
import * as TimerProgress from './timer-progress';
|
|
24
|
+
import * as WeakSpot from './weak-spot';
|
|
25
|
+
import * as Wordset from './wordset';
|
|
26
26
|
|
|
27
27
|
let failReason = '';
|
|
28
28
|
|
|
@@ -436,7 +436,7 @@ async function getNextWord(
|
|
|
436
436
|
let rq: MonkeyTypes.Quote | undefined | null = undefined;
|
|
437
437
|
rq = randomQuote;
|
|
438
438
|
|
|
439
|
-
if (rq !==
|
|
439
|
+
if (rq !== undefined && rq !== null) {
|
|
440
440
|
rq.text = rq.text.replace(/ +/gm, ' ');
|
|
441
441
|
rq.text = rq.text.replace(/\\\\t/gm, '\t');
|
|
442
442
|
rq.text = rq.text.replace(/\\\\n/gm, '\n');
|
|
@@ -643,7 +643,7 @@ export async function init(): Promise<void> {
|
|
|
643
643
|
const randomQuote = QuotesController.getRandomQuote();
|
|
644
644
|
rq = randomQuote;
|
|
645
645
|
|
|
646
|
-
if (rq ===
|
|
646
|
+
if (rq === undefined || rq === null) return;
|
|
647
647
|
|
|
648
648
|
rq.text = rq.text.replace(/ +/gm, ' ');
|
|
649
649
|
rq.text = rq.text.replace(/\\\\t/gm, '\t');
|
package/src/test-setup.ts
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
1
|
import 'jest-preset-angular/setup-jest';
|
|
2
|
+
|
|
3
|
+
// Global cleanup after each test
|
|
4
|
+
afterEach(() => {
|
|
5
|
+
// Clear all timers
|
|
6
|
+
jest.clearAllTimers();
|
|
7
|
+
|
|
8
|
+
// Clear all mocks
|
|
9
|
+
jest.clearAllMocks();
|
|
10
|
+
|
|
11
|
+
// Clean up any DOM elements that might be lingering
|
|
12
|
+
const testContainers = document.querySelectorAll('[data-testid]');
|
|
13
|
+
testContainers.forEach((element) => {
|
|
14
|
+
try {
|
|
15
|
+
element.remove();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
// Ignore errors during cleanup
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|