Skip to content

Commit

Permalink
corrected unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Mar 8, 2019
1 parent 466d839 commit 74ae804
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/unittests/common/services/testsStatusService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class TestsStatusUpdaterService implements ITestsStatusUpdaterService {
}
const predicate = (item: TestDataItem) => item.status === TestStatus.Fail || item.status === TestStatus.Error;
const visitor = (item: TestDataItem) => {
if (item.status && predicate(item)){
if (item.status && predicate(item)) {
item.status = TestStatus.Running;
this.storage.update(resource, item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ suite('Unit Tests - Tests Status Updater', () => {
tests.testFiles[3].status = TestStatus.Error;
tests.testFunctions[2].testFunction.status = TestStatus.Fail;
tests.testFunctions[3].testFunction.status = TestStatus.Error;
tests.testFunctions[4].testFunction.status = TestStatus.Pass;
tests.testSuites[1].testSuite.status = TestStatus.Fail;
tests.testSuites[2].testSuite.status = TestStatus.Error;

Expand All @@ -168,7 +169,11 @@ suite('Unit Tests - Tests Status Updater', () => {

// Update status of test functions and suites.
const updatedItems: TestDataItem[] = [];
const visitor = (item: TestDataItem) => updatedItems.push(item);
const visitor = (item: TestDataItem) => {
if (item.status && item.status !== TestStatus.Pass) {
updatedItems.push(item);
}
};
const failedItems = [
tests.testFunctions[2].testFunction,
tests.testFunctions[3].testFunction,
Expand All @@ -182,6 +187,9 @@ suite('Unit Tests - Tests Status Updater', () => {
verify(storage.update(workspaceUri, item)).once();
}

// Only items with status Fail & Error should be modified
assert.equal(tests.testFunctions[4].testFunction.status, TestStatus.Pass);

// Should only be called for failed items.
verify(storage.update(workspaceUri, anything())).times(updatedItems.length);
});
Expand Down

0 comments on commit 74ae804

Please sign in to comment.