Skip to content

Commit

Permalink
# gap
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <[email protected]>
  • Loading branch information
nhtruong committed May 21, 2024
1 parent 1e61148 commit f6772b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
9 changes: 0 additions & 9 deletions playground.ts

This file was deleted.

20 changes: 11 additions & 9 deletions tools/src/tester/ResultsDisplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ function gray (text: string): string { return `\x1b[90m${text}\x1b[0m` }
function magenta (text: string): string { return `\x1b[35m${text}\x1b[0m` }

export default class ResultsDisplayer {
gap: number
evaluation: StoryEvaluation
skip_components: boolean
ignore_passed: boolean = true
ignore_skipped: boolean = false

constructor (evaluation: StoryEvaluation) {
constructor (evaluation: StoryEvaluation, gap: number = 4) {
this.evaluation = evaluation
this.skip_components = [Result.PASSED, Result.SKIPPED].includes(evaluation.result)
console.log(YAML.stringify(evaluation, null, 2))
this.gap = gap
}

display (ignore_skipped = false, ignore_passed = true): void {
Expand All @@ -36,6 +37,7 @@ export default class ResultsDisplayer {
this.#display_chapters(this.evaluation.prologues ?? [], 'PROLOGUES')
this.#display_chapters(this.evaluation.chapters ?? [], 'CHAPTERS')
this.#display_chapters(this.evaluation.epilogues ?? [], 'EPILOGUES')
console.log('\n')
}

#display_story (): void {
Expand All @@ -48,13 +50,13 @@ export default class ResultsDisplayer {
#display_chapters (evaluations: ChapterEvaluation[], title: string): void {
if (this.skip_components || evaluations.length === 0) return
const result = overall_result(evaluations)
this.#display_evaluation({ result }, title, 3)
this.#display_evaluation({ result }, title, this.gap)
if (result === Result.PASSED) return
for (const evaluation of evaluations) this.#display_chapter(evaluation)
}

#display_chapter (chapter: ChapterEvaluation): void {
this.#display_evaluation(chapter, i(chapter.title), 6)
this.#display_evaluation(chapter, i(chapter.title), this.gap * 2)
if (chapter.result === Result.PASSED || chapter.result === Result.SKIPPED) return

this.#display_parameters(chapter.request?.parameters ?? {})
Expand All @@ -66,26 +68,26 @@ export default class ResultsDisplayer {
#display_parameters (parameters: Record<string, Evaluation>): void {
if (Object.keys(parameters).length === 0) return
const result = overall_result(Object.values(parameters))
this.#display_evaluation({ result }, 'PARAMETERS', 9)
this.#display_evaluation({ result }, 'PARAMETERS', this.gap * 3)
if (result === Result.PASSED) return
for (const [name, evaluation] of Object.entries(parameters)) {
this.#display_evaluation(evaluation, name, 12)
this.#display_evaluation(evaluation, name, this.gap * 4)
}
}

#display_request_body (evaluation: Evaluation | undefined): void {
if (evaluation == null) return
this.#display_evaluation(evaluation, 'REQUEST BODY', 9)
this.#display_evaluation(evaluation, 'REQUEST BODY', this.gap * 3)
}

#display_status (evaluation: Evaluation | undefined): void {
if (evaluation == null) return
this.#display_evaluation(evaluation, 'RESPONSE STATUS', 9)
this.#display_evaluation(evaluation, 'RESPONSE STATUS', this.gap * 3)
}

#display_payload (evaluation: Evaluation | undefined): void {
if (evaluation == null) return
this.#display_evaluation(evaluation, 'RESPONSE PAYLOAD', 9)
this.#display_evaluation(evaluation, 'RESPONSE PAYLOAD', this.gap * 3)
}

#display_evaluation (evaluation: Evaluation, title: string, prefix: number = 0): void {
Expand Down
2 changes: 1 addition & 1 deletion tools/src/tester/TestsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class TestsRunner {
const evaluations = await this.evaluate()
for (const evaluation of evaluations) {
const displayer = new ResultsDisplayer(evaluation)
displayer.display()
displayer.display(false, false)
}
}

Expand Down

0 comments on commit f6772b8

Please sign in to comment.