Skip to content

Commit

Permalink
Added implicit names test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aboisier committed Dec 15, 2018
1 parent eee38b9 commit 7a4fa81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/spec/decorators/testDecorator/testDecorator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Report } from '../../../lib/reporting/report/report';
import { TestsRunnerVisitor } from '../../../lib/tests/visitors/runnerVisitor';
import { TestSuite } from '../../../lib/tests/testSuite';
import { SingleTestTestDecoratorTestSuite } from './singleTestTestDecoratorTestSuite';
import { FailedTestsReportVisitor } from '../../../lib/tests/visitors/failedTestsReportVisitor';

@testSuite('Test Decorator Test Suite')
export class TestDecoratorTestSuite {
Expand Down Expand Up @@ -77,12 +78,17 @@ export class TestDecoratorTestSuite {
@test('no names, should infer from method names')
private async noNameTest() {
// Arrange
const testSuite = (TestWithNoNamesTestSuite as any).__testSuiteInstance;

// Act
const report = testSuite.accept(this.visitor);
const testSuite = this.getTestSuiteInstance(TestWithNoNamesTestSuite);

// Assert
expect.toBeIn('myTest1', testSuite.testIds);
expect.toBeIn('myTest2', testSuite.testIds);
expect.toBeIn('myTest3', testSuite.testIds);

const myTest3 = testSuite.get('myTest3') as TestSuite;
expect.toBeIn('myTestCase1', myTest3.testIds);
expect.toBeIn('myTestCase2', myTest3.testIds);
expect.toBeIn('myTestCase3', myTest3.testIds);
}

protected getTestSuiteInstance(testClass: any): TestSuite {
Expand Down
6 changes: 3 additions & 3 deletions src/spec/decorators/testDecorator/testWithoutNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class TestWithNoNamesTestSuite {
private myTest2() { }

@test(undefined, [
new TestCase('testCase1'),
new TestCase('testCase2'),
new TestCase('testCase3')
new TestCase('myTestCase1'),
new TestCase('myTestCase2'),
new TestCase('myTestCase3')
])
private myTest3() { }
}

0 comments on commit 7a4fa81

Please sign in to comment.