1- //
1+
22// Note: This example test is leveraging the Mocha test framework.
33// Please refer to their documentation on https://mochajs.org/ for help.
4- //
4+
55
66// The module 'assert' provides assertion methods from node
77import * as assert from "assert" ;
@@ -14,18 +14,15 @@ import {YapfFormatter} from "../client/formatters/yapfFormatter";
1414import * as path from "path" ;
1515import * as settings from "../client/common/configSettings" ;
1616import * as fs from "fs-extra" ;
17+ import { initialize } from "./initialize" ;
1718
1819let pythonSettings = settings . PythonSettings . getInstance ( ) ;
1920let ch = vscode . window . createOutputChannel ( "Tests" ) ;
2021let pythoFilesPath = path . join ( __dirname , ".." , ".." , "src" , "test" , "pythonFiles" , "formatting" ) ;
2122
2223suite ( "Formatting" , ( ) => {
23- setup ( ( ) => {
24- return new Promise < any > ( resolve => {
25- setTimeout ( function ( ) {
26- resolve ( ) ;
27- } , 1000 ) ;
28- } ) ;
24+ setup ( done => {
25+ initialize ( ) . then ( ( ) => done ( ) , done ) ;
2926 } ) ;
3027 teardown ( ( ) => {
3128 if ( vscode . window . activeTextEditor ) {
@@ -56,10 +53,7 @@ suite("Formatting", () => {
5653 }
5754 assert . equal ( textEditor . document . getText ( ) , data , "Formatted text is not the same" ) ;
5855 } ) ;
59- } ) . then ( done , error => {
60- done ( ) ;
61- assert . ok ( false , error ) ;
62- } ) ;
56+ } ) . then ( done , done ) ;
6357 } ) ;
6458
6559 test ( "Yapf" , done => {
@@ -85,10 +79,7 @@ suite("Formatting", () => {
8579 }
8680 assert . equal ( textEditor . document . getText ( ) , data , "Formatted text is not the same" ) ;
8781 } ) ;
88- } ) . then ( done , error => {
89- done ( ) ;
90- assert . ok ( false , error ) ;
91- } ) ;
82+ } ) . then ( done , done ) ;
9283 } ) ;
9384
9485 test ( "Yapf autoformat on save" , done => {
@@ -120,9 +111,6 @@ suite("Formatting", () => {
120111 } ) ;
121112 } ) . then ( ( ) => {
122113 assert . equal ( textDocument . getText ( ) , formattedFileContents , "Formatted contents are not the same" ) ;
123- } ) . then ( done , error => {
124- done ( ) ;
125- assert . ok ( false , error ) ;
126- } ) ;
114+ } ) . then ( done , done ) ;
127115 } ) ;
128116} ) ;
0 commit comments