@@ -4,48 +4,48 @@ import * as utils from '../../client/testing/utils';
44import sinon from 'sinon' ;
55use ( chaiAsPromised . default ) ;
66
7- describe ( 'idToModuleClassMethod' , ( ) => {
8- it ( 'returns the only part if there is one' , ( ) => {
7+ function test_idToModuleClassMethod ( ) {
8+ try {
99 expect ( utils . idToModuleClassMethod ( 'foo' ) ) . to . equal ( 'foo' ) ;
10- } ) ;
11- it ( 'returns module.class for two parts' , ( ) => {
12- expect ( utils . idToModuleClassMethod ( 'a/b/c.py\\MyClass' ) ) . to . equal ( 'c.MyClass' ) ;
13- } ) ;
14- it ( 'returns module.class.method for three parts' , ( ) => {
15- expect ( utils . idToModuleClassMethod ( 'a/b/c.py\\MyClass\\my_method' ) ) . to . equal ( 'c.MyClass.my_method' ) ;
16- } ) ;
17- it ( 'returns undefined if fileName is missing' , ( ) => {
10+ expect ( utils . idToModuleClassMethod ( 'a/b/c.pyMyClass' ) ) . to . equal ( 'c.MyClass' ) ;
11+ expect ( utils . idToModuleClassMethod ( 'a/b/c.pyMyClassmy_method' ) ) . to . equal ( 'c.MyClass.my_method' ) ;
1812 expect ( utils . idToModuleClassMethod ( '\\MyClass' ) ) . to . be . undefined ;
19- } ) ;
20- } ) ;
13+ console . log ( 'test_idToModuleClassMethod passed' ) ;
14+ } catch ( e ) {
15+ console . error ( 'test_idToModuleClassMethod failed:' , e ) ;
16+ }
17+ }
2118
22- describe ( 'writeTestIdToClipboard' , ( ) => {
23- let clipboardStub : sinon . SinonStub ;
24-
25- afterEach ( ( ) => {
26- sinon . restore ( ) ;
27- } ) ;
28-
29- it ( 'writes module.class.method for unittest id' , async ( ) => {
30- clipboardStub = sinon . stub ( utils , 'clipboardWriteText' ) . resolves ( ) ;
31- const { writeTestIdToClipboard } = utils ;
32- const testItem = { id : 'a/b/c.py\\MyClass\\my_method' } ;
19+ async function test_writeTestIdToClipboard ( ) {
20+ let clipboardStub = sinon . stub ( utils , 'clipboardWriteText' ) . resolves ( ) ;
21+ const { writeTestIdToClipboard } = utils ;
22+ try {
23+ // unittest id
24+ const testItem = { id : 'a/b/c.pyMyClass\\my_method' } ;
3325 await writeTestIdToClipboard ( testItem as any ) ;
3426 sinon . assert . calledOnceWithExactly ( clipboardStub , 'c.MyClass.my_method' ) ;
35- } ) ;
27+ clipboardStub . resetHistory ( ) ;
3628
37- it ( 'writes id as is for pytest id' , async ( ) => {
38- clipboardStub = sinon . stub ( utils , 'clipboardWriteText' ) . resolves ( ) ;
39- const { writeTestIdToClipboard } = utils ;
40- const testItem = { id : 'tests/test_foo.py::TestClass::test_method' } ;
41- await writeTestIdToClipboard ( testItem as any ) ;
29+ // pytest id
30+ const testItem2 = { id : 'tests/test_foo.py::TestClass::test_method' } ;
31+ await writeTestIdToClipboard ( testItem2 as any ) ;
4232 sinon . assert . calledOnceWithExactly ( clipboardStub , 'tests/test_foo.py::TestClass::test_method' ) ;
43- } ) ;
33+ clipboardStub . resetHistory ( ) ;
4434
45- it ( 'does nothing if testItem is undefined' , async ( ) => {
46- clipboardStub = sinon . stub ( utils , 'clipboardWriteText' ) . resolves ( ) ;
47- const { writeTestIdToClipboard } = utils ;
35+ // undefined
4836 await writeTestIdToClipboard ( undefined as any ) ;
4937 sinon . assert . notCalled ( clipboardStub ) ;
50- } ) ;
51- } ) ;
38+
39+ console . log ( 'test_writeTestIdToClipboard passed' ) ;
40+ } catch ( e ) {
41+ console . error ( 'test_writeTestIdToClipboard failed:' , e ) ;
42+ } finally {
43+ sinon . restore ( ) ;
44+ }
45+ }
46+
47+ // Run tests
48+ ( async ( ) => {
49+ test_idToModuleClassMethod ( ) ;
50+ await test_writeTestIdToClipboard ( ) ;
51+ } ) ( ) ;
0 commit comments