quarc/tests/unit
Michał Sieciechowicz 72f5d249cf pipe part 2 2026-01-18 23:11:30 +01:00
..
compiled alias in @if statement 2026-01-18 11:23:53 +01:00
README.md initial commit 2026-01-16 10:27:30 +01:00
package.json initial commit 2026-01-16 10:27:30 +01:00
run-tests.sh initial commit 2026-01-16 10:27:30 +01:00
run-tests.ts alias in @if statement 2026-01-18 11:23:53 +01:00
test-devices-component.html pipes 2026-01-18 21:29:07 +01:00
test-devices-component.ts pipes 2026-01-18 21:29:07 +01:00
test-directives.ts initial commit 2026-01-16 10:27:30 +01:00
test-for-transformation.ts pipes 2026-01-18 21:29:07 +01:00
test-functionality.ts improve control flow transformer robustness and remove debug logs 2026-01-18 20:27:12 +01:00
test-inject.ts fix naming and add inject method 2026-01-17 11:27:05 +01:00
test-interpolation-transformation.ts pipes 2026-01-18 21:29:07 +01:00
test-lifecycle.ts initial commit 2026-01-16 10:27:30 +01:00
test-nested-for-loops.ts initial commit 2026-01-16 10:27:30 +01:00
test-ngif-alias.ts alias in @if statement 2026-01-18 11:23:53 +01:00
test-pipe-transformation-detailed.ts pipe part 2 2026-01-18 23:11:30 +01:00
test-pipe-with-logical-operators.ts pipe part 2 2026-01-18 23:11:30 +01:00
test-pipes-diagnostic.ts pipe part 2 2026-01-18 23:11:30 +01:00
test-pipes-e2e.html pipe part 2 2026-01-18 23:11:30 +01:00
test-pipes.ts pipe part 2 2026-01-18 23:11:30 +01:00
test-plugin-loading.ts initial commit 2026-01-16 10:27:30 +01:00
test-processors.ts alias in @if statement 2026-01-18 11:23:53 +01:00
test-router.ts initial commit 2026-01-16 10:27:30 +01:00
test-signals-reactivity.ts initial commit 2026-01-16 10:27:30 +01:00
test-style-injection.html initial commit 2026-01-16 10:27:30 +01:00
test-style-injection.ts initial commit 2026-01-16 10:27:30 +01:00
test-template-reactivity.ts initial commit 2026-01-16 10:27:30 +01:00
tsconfig.json initial commit 2026-01-16 10:27:30 +01:00

README.md

Testy Quarc Framework

Ta struktura zawiera wszystkie testy dla Quarc Framework.

Struktura

  • test-functionality.ts - Testy podstawowej funkcjonalności (ControlFlowTransformer, TemplateParser, etc.)
  • test-style-injection.ts - Testy wstrzykiwania stylów i transformacji :host
  • test-style-injection.html - Strona HTML do uruchamiania testów stylów w przeglądarce
  • test-lifecycle.ts - Testy interfejsów lifecycle (OnInit, OnDestroy, AfterViewInit, etc.)
  • run-tests.ts - Główny skrypt do uruchamiania wszystkich testów

Uruchamianie testów

Instalacja zależności

cd quarc/tests/unit
npm install

Wszystkie testy (jednostkowe + e2e)

npm test
# lub
npm run test:all

Tylko testy jednostkowe

npm run test:unit

Tylko testy e2e

npm run test:e2e

Indywidualne testy

# Testy funkcjonalne
npm run test:functionality

# Testy wstrzykiwania stylów
npm run test:style

# Testy lifecycle
npm run test:lifecycle

Testy w przeglądarce

npm run test:browser
# lub
xdg-open test-style-injection.html

Wymagania

  • ts-node - do uruchamiania testów TypeScript
  • @types/node - typy Node.js
  • Środowisko przeglądarki dla testów stylów (lub JSDOM)

Co testujemy?

Testy funkcjonalne

  • Transformacja @if na *ngIf
  • Transformacja @for na *ngFor
  • Parsowanie szablonów
  • Helpery dla dyrektyw strukturalnych

Testy wstrzykiwania stylów

  • Transformacja :host na [_nghost-scopeId]
  • Transformacja :host() z selektorami
  • Obsługa różnych ViewEncapsulation
  • Dodawanie atrybutów _nghost i _ngcontent
  • Wiele wystąpień :host w jednym pliku

Testy lifecycle

  • OnInit - ngOnInit()
  • OnDestroy - ngOnDestroy()
  • AfterViewInit - ngAfterViewInit()
  • AfterViewChecked - ngAfterViewChecked()
  • AfterContentInit - ngAfterContentInit()
  • AfterContentChecked - ngAfterContentChecked()
  • DoCheck - ngDoCheck()
  • OnChanges - ngOnChanges(changes: SimpleChanges)
  • Wielokrotna implementacja hooków
  • Poprawna kolejność wywołań lifecycle

Rozwój

Aby dodać nowy test:

  1. Stwórz nowy plik test-nazwa.ts w tym katalogu
  2. Dodaj go do listy testFiles w run-tests.ts
  3. Użyj funkcji test() z istniejących plików jako wzoru

Problemy

Jeśli testy stylów nie działają w Node.js, uruchom je w przeglądarce przez test-style-injection.html.