Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 27, 2019 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/eff99c24bd35a0bfc8b1e4eda83b5537 to your computer and use it in GitHub Desktop.
Save IntegerMan/eff99c24bd35a0bfc8b1e4eda83b5537 to your computer and use it in GitHub Desktop.
class TestManagerApp {
public testCases: TestCase[] = [];
public nextTestCaseId: number = 2;
constructor() {
this.buildInitialData();
}
public addTestCase() {
const textBox = <HTMLInputElement>document.getElementById('txtTestName');
const testCaseName = textBox.value;
if (testCaseName) {
const testCase = new TestCase(testCaseName, this.nextTestCaseId++);
this.testCases.push(testCase);
updateTestCases(this);
textBox.value = '';
} else {
alert('You must enter a test case name');
}
}
private buildInitialData(): TestCase[] {
return [{
name: 'The app should not crash on startup',
isPassing: true,
id: '1'
}];
}
public findTestCaseById(id: number) {
for (const testCase of this.testCases) {
if (testCase.id === id) return testCase;
}
return null;
}
public deleteTestCase(testCase: TestCase) {
const index = this.testCases.indexOf(testCase);
this.testCases.splice(index, 1);
updateTestCases(this);
}
}
const testManager: TestManagerApp = new TestManagerApp();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment