1
1
'use babel' ;
2
2
3
3
import { join } from 'path' ;
4
+ // eslint-disable-next-line no-unused-vars
5
+ import { it , fit , wait , beforeEach , afterEach } from 'jasmine-fix' ;
4
6
5
7
const goodPath = join ( __dirname , 'fixtures' , 'good.rb' ) ;
6
8
const badPath = join ( __dirname , 'fixtures' , 'bad.rb' ) ;
7
9
const { lint } = require ( '../lib/main.js' ) . provideLinter ( ) ;
8
10
9
11
describe ( 'The Ruby provider for Linter' , ( ) => {
10
- beforeEach ( ( ) => {
12
+ beforeEach ( async ( ) => {
11
13
// Info about this beforeEach() implementation:
12
14
// https://github.com/AtomLinter/Meta/issues/15
13
15
const activationPromise = atom . packages . activatePackage ( 'linter-ruby' ) ;
14
16
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 ) ;
18
19
19
20
atom . packages . triggerDeferredActivationHooks ( ) ;
20
- waitsForPromise ( ( ) => activationPromise ) ;
21
+ await activationPromise ;
21
22
} ) ;
22
23
23
24
it ( 'should be in the packages list' , ( ) =>
@@ -26,38 +27,28 @@ describe('The Ruby provider for Linter', () => {
26
27
it ( 'should be an active package' , ( ) =>
27
28
expect ( atom . packages . isPackageActive ( 'linter-ruby' ) ) . toBe ( true ) ) ;
28
29
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 ] ] ) ;
53
47
} ) ;
54
48
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 ) ;
62
53
} ) ;
63
54
} ) ;
0 commit comments