11'use babel' ;
22
33import { join } from 'path' ;
4+ // eslint-disable-next-line no-unused-vars
5+ import { it , fit , wait , beforeEach , afterEach } from 'jasmine-fix' ;
46
57const goodPath = join ( __dirname , 'fixtures' , 'good.rb' ) ;
68const badPath = join ( __dirname , 'fixtures' , 'bad.rb' ) ;
79const { lint } = require ( '../lib/main.js' ) . provideLinter ( ) ;
810
911describe ( 'The Ruby provider for Linter' , ( ) => {
10- beforeEach ( ( ) => {
12+ beforeEach ( async ( ) => {
1113 // Info about this beforeEach() implementation:
1214 // https://github.com/AtomLinter/Meta/issues/15
1315 const activationPromise = atom . packages . activatePackage ( 'linter-ruby' ) ;
1416
15- waitsForPromise ( ( ) =>
16- atom . packages . activatePackage ( 'language-ruby' ) . then ( ( ) =>
17- atom . workspace . open ( goodPath ) ) ) ;
17+ await atom . packages . activatePackage ( 'language-ruby' ) ;
18+ await atom . workspace . open ( goodPath ) ;
1819
1920 atom . packages . triggerDeferredActivationHooks ( ) ;
20- waitsForPromise ( ( ) => activationPromise ) ;
21+ await activationPromise ;
2122 } ) ;
2223
2324 it ( 'should be in the packages list' , ( ) =>
@@ -26,38 +27,28 @@ describe('The Ruby provider for Linter', () => {
2627 it ( 'should be an active package' , ( ) =>
2728 expect ( atom . packages . isPackageActive ( 'linter-ruby' ) ) . toBe ( true ) ) ;
2829
29- describe ( 'checks bad.rb and' , ( ) => {
30- let editor = null ;
31- beforeEach ( ( ) => {
32- waitsForPromise ( ( ) =>
33- atom . workspace . open ( badPath ) . then ( ( openEditor ) => { editor = openEditor ; } ) ) ;
34- } ) ;
35-
36- it ( 'verifies the messages are correct' , ( ) =>
37- waitsForPromise ( ( ) =>
38- lint ( editor ) . then ( ( messages ) => {
39- expect ( messages . length ) . toBe ( 2 ) ;
40-
41- expect ( messages [ 0 ] . type ) . toBe ( 'Warning' ) ;
42- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
43- expect ( messages [ 0 ] . text ) . toBe ( 'assigned but unused variable - payload' ) ;
44- expect ( messages [ 0 ] . filePath ) . toBe ( badPath ) ;
45- expect ( messages [ 0 ] . range ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 13 ] ] ) ;
46-
47- expect ( messages [ 1 ] . type ) . toBe ( 'Error' ) ;
48- expect ( messages [ 1 ] . html ) . not . toBeDefined ( ) ;
49- expect ( messages [ 1 ] . text ) . toBe ( 'unexpected keyword_end, expecting end-of-input' ) ;
50- expect ( messages [ 1 ] . filePath ) . toBe ( badPath ) ;
51- expect ( messages [ 1 ] . range ) . toEqual ( [ [ 12 , 0 ] , [ 12 , 18 ] ] ) ;
52- } ) ) ) ;
30+ it ( 'checks bad.rb and verifies the messages are correct' , async ( ) => {
31+ const editor = await atom . workspace . open ( badPath ) ;
32+ const messages = await lint ( editor ) ;
33+
34+ expect ( messages . length ) . toBe ( 2 ) ;
35+
36+ expect ( messages [ 0 ] . type ) . toBe ( 'Warning' ) ;
37+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
38+ expect ( messages [ 0 ] . text ) . toBe ( 'assigned but unused variable - payload' ) ;
39+ expect ( messages [ 0 ] . filePath ) . toBe ( badPath ) ;
40+ expect ( messages [ 0 ] . range ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 13 ] ] ) ;
41+
42+ expect ( messages [ 1 ] . type ) . toBe ( 'Error' ) ;
43+ expect ( messages [ 1 ] . html ) . not . toBeDefined ( ) ;
44+ expect ( messages [ 1 ] . text ) . toBe ( 'unexpected keyword_end, expecting end-of-input' ) ;
45+ expect ( messages [ 1 ] . filePath ) . toBe ( badPath ) ;
46+ expect ( messages [ 1 ] . range ) . toEqual ( [ [ 12 , 0 ] , [ 12 , 18 ] ] ) ;
5347 } ) ;
5448
55- describe ( 'checks good.rb and' , ( ) => {
56- it ( 'reports nothing wrong' , ( ) =>
57- waitsForPromise ( ( ) =>
58- atom . workspace . open ( goodPath ) . then ( editor =>
59- lint ( editor ) . then ( ( messages ) => {
60- expect ( messages . length ) . toBe ( 0 ) ;
61- } ) ) ) ) ;
49+ it ( 'checks good.rb and reports nothing wrong' , async ( ) => {
50+ const editor = await atom . workspace . open ( goodPath ) ;
51+ const messages = await lint ( editor ) ;
52+ expect ( messages . length ) . toBe ( 0 ) ;
6253 } ) ;
6354} ) ;
0 commit comments