Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.