Skip to content

Commit

Permalink
Merge pull request #211 from BinaryStudioAcademy/bugfix-95/sample-tes…
Browse files Browse the repository at this point in the history
…t-switch

Fix language switch issue
  • Loading branch information
Illusion4 committed Sep 28, 2023
2 parents 89ea4c8 + 4e50f77 commit b6b053c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
class="my-code-editor"
[initText]="initialSolution!"
[language]="selectedLanguage"
[(ngModel)]="initialSolution"
(codeChanged)="onCodeChanged($event)"
[options]="editorOptions"></app-code-editor>
</div>
Expand All @@ -70,7 +69,6 @@
class="my-code-editor"
[options]="editorOptions"
[language]="selectedLanguage"
[(ngModel)]="testCode"
(codeChanged)="onTestChanged($event)"
[initText]="testCode!"></app-code-editor>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export class OnlineEditorPageComponent extends BaseComponent implements OnDestro

onSelectedLanguageChanged($event: string | string[]): void {
this.initialSolution = this.getInitialSolutionByLanguage($event as string)!;

this.testCode = this.getInitialTestsByLanguage($event as string);
}

onCodeChanged(newCode: string) {
Expand Down Expand Up @@ -237,6 +239,12 @@ export class OnlineEditorPageComponent extends BaseComponent implements OnDestro
this.editorOptions = editorOptions;
}

private getInitialTestsByLanguage(language: string): string {
const version = this.challenge.versions?.find((v) => v.language.name === language);

return version?.exampleTestCases ?? 'No tests available';
}

private getInitialSolutionByLanguage(language: string): string {
const version = this.challenge.versions?.find((v) => v.language.name === language);

Expand Down

0 comments on commit b6b053c

Please sign in to comment.