1414 limitations under the License.
1515*/
1616import { expect } from 'chai' ;
17- import { describe , it , beforeEach , afterEach } from "mocha" ;
17+ import { describe , it , beforeEach , before , after } from "mocha" ;
1818import * as sinon from 'sinon' ;
1919import * as vscode from 'vscode' ;
20- import { Extension } from 'vscode' ;
20+ import { Extension } from 'vscode' ;
2121import { LOGGER } from '../../../logger' ;
22- import { mock , instance , when , reset } from "ts-mockito" ;
23- var l10n :any = null ;
22+ import { mock , instance , when , reset } from "ts-mockito" ;
23+ var l10n : any = null ;
2424import * as path from 'path' ;
2525import assert = require( 'assert' ) ;
2626
2727describe ( 'localiser tests' , ( ) => {
2828 let loggerLogStub : sinon . SinonStub ;
29- let mockedExtns : typeof vscode . extensions ;
30- let extMock : Extension < any > ;
31- let mockedEnv : typeof vscode . env ;
32- let mockedL10n : typeof vscode . l10n ;
33- let currentDir = __dirname ;
34-
29+ let mockedExtns : typeof vscode . extensions ;
30+ let extMock : Extension < any > ;
31+ let mockedEnv : typeof vscode . env ;
32+ let mockedL10n : typeof vscode . l10n ;
33+ let currentDir = __dirname . replace ( "/out/" , "/src/" ) ;
34+
3535 before ( ( ) => {
36- let vscodeObj = ( vscode as typeof vscode & { mockedExtns : typeof vscode . extensions , mockedEnv : typeof vscode . env , mockedL10n : typeof vscode . l10n } ) ;
36+ let vscodeObj = ( vscode as typeof vscode & { mockedExtns : typeof vscode . extensions , mockedEnv : typeof vscode . env , mockedL10n : typeof vscode . l10n } ) ;
3737 mockedExtns = vscodeObj . mockedExtns ;
3838 mockedEnv = vscodeObj . mockedEnv ;
3939 mockedL10n = vscodeObj . mockedL10n ;
4040 extMock = mock < Extension < any > > ( ) ;
41- loggerLogStub = sinon . stub ( LOGGER , "error" ) ;
42-
43-
41+ loggerLogStub = sinon . stub ( LOGGER , "error" ) ;
4442 } ) ;
45- beforeEach ( ( ) => {
43+ beforeEach ( ( ) => {
4644 sinon . reset ( ) ;
4745 reset ( mockedExtns ) ;
4846 reset ( extMock ) ;
@@ -61,32 +59,32 @@ describe('localiser tests', () => {
6159 describe ( 'l10n tests' , ( ) => {
6260 describe ( 'issue while reading bundle' , ( ) => {
6361 it ( 'file not found error' , ( ) => {
64- let msg :string | null = null ;
62+ let msg : string | null = null ;
6563 when ( extMock ?. extensionPath ) . thenReturn ( path . join ( currentDir , 'doesnt-exist' ) ) ;
6664 var mkInst = instance ( extMock ) ;
6765 when ( mockedExtns . getExtension ( "oracle.oracle-java" ) ) . thenReturn ( mkInst ) ;
68- try {
66+ try {
6967 l10n = require ( '../../../localiser' ) ;
70- } catch ( e ) {
71- msg = ( e as any & { message :string } ) . message
68+ } catch ( e ) {
69+ msg = ( e as any & { message : string } ) . message
7270 }
73- assert . strictEqual ( msg ! ! . includes ( "no such file or directory" ) , true ) ;
71+ assert . strictEqual ( msg ! ! . includes ( "no such file or directory" ) , true ) ;
7472 expect ( loggerLogStub . called ) . to . be . true ;
7573 } ) ;
7674 it ( 'file parsing error' , ( ) => {
77- let msg :string | null = null ;
78- when ( extMock ?. extensionPath ) . thenReturn ( path . join ( currentDir , 'resources' , 'corrupt' ) ) ;
75+ let msg : string | null = null ;
76+ when ( extMock ?. extensionPath ) . thenReturn ( path . join ( currentDir , 'resources' , 'corrupt' ) ) ;
7977 var mkInst = instance ( extMock ) ;
8078 when ( mockedExtns . getExtension ( "oracle.oracle-java" ) ) . thenReturn ( mkInst ) ;
81- try {
79+ try {
8280 l10n = require ( '../../../localiser' ) ;
83- } catch ( e ) {
84- msg = ( e as any & { message :string } ) . message
81+ } catch ( e ) {
82+ msg = ( e as any & { message : string } ) . message
8583 }
86- assert . strictEqual ( msg ! ! . includes ( "Bad control character in string literal in JSON" ) , true ) ;
84+ assert . strictEqual ( msg ! ! . includes ( "Bad control character in string literal in JSON" ) , true ) ;
8785 expect ( loggerLogStub . called ) . to . be . true ;
8886 } ) ;
89-
87+
9088 } ) ;
9189 describe ( 'l10n initialisation tests' , ( ) => {
9290 it ( 'l10n initialized' , ( ) => {
@@ -103,10 +101,10 @@ describe('localiser tests', () => {
103101 when ( mockedExtns . getExtension ( "oracle.oracle-java" ) ) . thenReturn ( mkExtInst ) ;
104102 when ( mockedL10n . bundle ) . thenReturn ( undefined ) ;
105103 let l10n = require ( '../../../localiser' ) ;
106- let l10nObj = l10n . l10n as { nbLocaleCode ( ) : string , value ( key : string , placeholderMap ?: Record < string , any > ) : string } ;
107- assert . strictEqual ( l10nObj . nbLocaleCode ( ) , "en" ) ;
108- assert . strictEqual ( l10nObj . value ( "label1" ) , "label1 description" ) ;
109- assert . strictEqual ( l10nObj . value ( "label2" , { "placeholder1" :"sample data" } ) , "lable2 sample data description" ) ;
104+ let l10nObj = l10n . l10n as { nbLocaleCode ( ) : string , value ( key : string , placeholderMap ?: Record < string , any > ) : string } ;
105+ assert . strictEqual ( l10nObj . nbLocaleCode ( ) , "en" ) ;
106+ assert . strictEqual ( l10nObj . value ( "label1" ) , "label1 description" ) ;
107+ assert . strictEqual ( l10nObj . value ( "label2" , { "placeholder1" : "sample data" } ) , "lable2 sample data description" ) ;
110108 expect ( loggerLogStub . called ) . to . be . false ;
111109 } ) ;
112110 } ) ;
0 commit comments