Created
October 27, 2019 04:27
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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