1
1
'use babel' ;
2
2
3
3
import { join } from 'path' ;
4
- // eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved
5
4
import { remove } from 'fs-extra' ;
5
+ // eslint-disable-next-line no-unused-vars
6
+ import { it , fit , wait , beforeEach , afterEach } from 'jasmine-fix' ;
6
7
7
8
const { lint } = require ( '../lib/init.js' ) . provideLinter ( ) ;
8
9
@@ -19,138 +20,115 @@ const mixBuildDirectory = join(__dirname, 'fixtures', 'mix-proj', '_build');
19
20
remove ( mixBuildDirectory ) ;
20
21
21
22
describe ( 'The elixirc provider for Linter' , ( ) => {
23
+ beforeEach ( async ( ) => {
24
+ atom . workspace . destroyActivePaneItem ( ) ;
25
+
26
+ await atom . packages . activatePackage ( 'linter-elixirc' ) ;
27
+ await atom . packages . activatePackage ( 'language-elixir' ) ;
28
+ } ) ;
29
+
22
30
describe ( 'when not working inside a Mix project' , ( ) => {
23
31
describe ( 'and using the standard configuration' , ( ) => {
24
- beforeEach ( ( ) => {
25
- atom . workspace . destroyActivePaneItem ( ) ;
26
-
27
- waitsForPromise ( ( ) =>
28
- Promise . all ( [
29
- atom . packages . activatePackage ( 'linter-elixirc' ) ,
30
- atom . packages . activatePackage ( 'language-elixir' ) ,
31
- ] ) ) ;
32
- } ) ;
32
+ it ( 'works with mode 1 errors' , async ( ) => {
33
+ const editor = await atom . workspace . open ( errorMode1PathElixirc ) ;
34
+ const messages = await lint ( editor ) ;
33
35
34
- it ( 'works with mode 1 errors' , ( ) => {
35
- waitsForPromise ( ( ) =>
36
- atom . workspace . open ( errorMode1PathElixirc ) . then ( editor =>
37
- lint ( editor ) ) . then ( ( messages ) => {
38
- expect ( messages . length ) . toBe ( 1 ) ;
39
- expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
40
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
41
- expect ( messages [ 0 ] . excerpt ) . toBe ( '(ArgumentError) Dangerous is not available' ) ;
42
- expect ( messages [ 0 ] . location . file ) . toBe ( errorMode1PathElixirc ) ;
43
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 0 ] , [ 1 , 32 ] ] ) ;
44
- } ) ) ;
36
+ expect ( messages . length ) . toBe ( 1 ) ;
37
+ expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
38
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
39
+ expect ( messages [ 0 ] . excerpt ) . toBe ( '(ArgumentError) Dangerous is not available' ) ;
40
+ expect ( messages [ 0 ] . location . file ) . toBe ( errorMode1PathElixirc ) ;
41
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 0 ] , [ 1 , 32 ] ] ) ;
45
42
} ) ;
46
43
47
- it ( 'works with mode 2 errors' , ( ) => {
48
- waitsForPromise ( ( ) =>
49
- atom . workspace . open ( errorMode2PathElixirc ) . then ( editor =>
50
- lint ( editor ) ) . then ( ( messages ) => {
51
- expect ( messages . length ) . toBe ( 1 ) ;
52
- expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
53
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
54
- expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) module Usefulness is not loaded and could not be found' ) ;
55
- expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathElixirc ) ;
56
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 3 , 2 ] , [ 3 , 20 ] ] ) ;
57
- } ) ) ;
44
+ it ( 'works with mode 2 errors' , async ( ) => {
45
+ const editor = await atom . workspace . open ( errorMode2PathElixirc ) ;
46
+ const messages = await lint ( editor ) ;
47
+
48
+ expect ( messages . length ) . toBe ( 1 ) ;
49
+ expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
50
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
51
+ expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) module Usefulness is not loaded and could not be found' ) ;
52
+ expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathElixirc ) ;
53
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 3 , 2 ] , [ 3 , 20 ] ] ) ;
58
54
} ) ;
59
55
60
- it ( 'works with warnings' , ( ) => {
61
- waitsForPromise ( ( ) =>
62
- atom . workspace . open ( warningPathElixirc ) . then ( editor => lint ( editor ) ) . then ( ( messages ) => {
63
- expect ( messages . length ) . toBe ( 1 ) ;
64
- expect ( messages [ 0 ] . severity ) . toBe ( 'warning' ) ;
65
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
66
- expect ( messages [ 0 ] . excerpt ) . toBe ( 'variable "prepare_for_call" does not exist and is being expanded to "prepare_for_call()", please use parentheses to remove the ambiguity or change the variable name' ) ;
67
- expect ( messages [ 0 ] . location . file ) . toBe ( warningPathElixirc ) ;
68
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 20 , 4 ] , [ 20 , 20 ] ] ) ;
69
- } ) ) ;
56
+ it ( 'works with warnings' , async ( ) => {
57
+ const editor = await atom . workspace . open ( warningPathElixirc ) ;
58
+ const messages = await lint ( editor ) ;
59
+
60
+ expect ( messages . length ) . toBe ( 1 ) ;
61
+ expect ( messages [ 0 ] . severity ) . toBe ( 'warning' ) ;
62
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
63
+ expect ( messages [ 0 ] . excerpt ) . toBe ( 'variable "prepare_for_call" does not exist and is being expanded to "prepare_for_call()", please use parentheses to remove the ambiguity or change the variable name' ) ;
64
+ expect ( messages [ 0 ] . location . file ) . toBe ( warningPathElixirc ) ;
65
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 20 , 4 ] , [ 20 , 20 ] ] ) ;
70
66
} ) ;
71
67
72
- it ( 'works with .exs files' , ( ) => {
73
- waitsForPromise ( ( ) =>
74
- atom . workspace . open ( exsFilePathElixirc ) . then ( editor => lint ( editor ) ) . then ( ( messages ) => {
75
- expect ( messages . length ) . toBe ( 1 ) ;
76
- expect ( messages [ 0 ] . severity ) . toBe ( 'warning' ) ;
77
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
78
- expect ( messages [ 0 ] . excerpt ) . toBe ( 'function simple_function/0 is unused' ) ;
79
- expect ( messages [ 0 ] . location . file ) . toBe ( exsFilePathElixirc ) ;
80
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 25 ] ] ) ;
81
- } ) ) ;
68
+ it ( 'works with .exs files' , async ( ) => {
69
+ const editor = await atom . workspace . open ( exsFilePathElixirc ) ;
70
+ const messages = await lint ( editor ) ;
71
+
72
+ expect ( messages . length ) . toBe ( 1 ) ;
73
+ expect ( messages [ 0 ] . severity ) . toBe ( 'warning' ) ;
74
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
75
+ expect ( messages [ 0 ] . excerpt ) . toBe ( 'function simple_function/0 is unused' ) ;
76
+ expect ( messages [ 0 ] . location . file ) . toBe ( exsFilePathElixirc ) ;
77
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 25 ] ] ) ;
82
78
} ) ;
83
79
84
- it ( 'finds nothing wrong with a valid file' , ( ) => {
85
- waitsForPromise ( ( ) =>
86
- atom . workspace . open ( validPathElixirc ) . then ( editor => lint ( editor ) ) . then ( ( messages ) => {
87
- expect ( messages . length ) . toBe ( 0 ) ;
88
- } ) ) ;
80
+ it ( 'finds nothing wrong with a valid file' , async ( ) => {
81
+ const editor = await atom . workspace . open ( validPathElixirc ) ;
82
+ const messages = await lint ( editor ) ;
83
+
84
+ expect ( messages . length ) . toBe ( 0 ) ;
89
85
} ) ;
90
86
} ) ;
91
87
} ) ;
92
88
93
89
describe ( 'when working inside a Mix project' , ( ) => {
94
90
describe ( 'and using the standard configuration' , ( ) => {
95
- beforeEach ( ( ) => {
96
- atom . workspace . destroyActivePaneItem ( ) ;
97
-
98
- waitsForPromise ( ( ) =>
99
- Promise . all ( [
100
- atom . packages . activatePackage ( 'linter-elixirc' ) ,
101
- atom . packages . activatePackage ( 'language-elixir' ) ,
102
- ] ) ) ;
103
- } ) ;
91
+ it ( 'works with mode 2 errors' , async ( ) => {
92
+ const editor = await atom . workspace . open ( errorMode2PathMix ) ;
93
+ const messages = await lint ( editor ) ;
104
94
105
- it ( 'works with mode 2 errors' , ( ) => {
106
- waitsForPromise ( ( ) =>
107
- atom . workspace . open ( errorMode2PathMix ) . then ( editor =>
108
- lint ( editor ) ) . then ( ( messages ) => {
109
- expect ( messages . length ) . toBe ( 1 ) ;
110
- expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
111
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
112
- expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) Identicon.Image.__struct__/1 is undefined, cannot expand struct Identicon.Image' ) ;
113
- expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathMix ) ;
114
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 11 , 4 ] , [ 11 , 30 ] ] ) ;
115
- } ) ) ;
95
+ expect ( messages . length ) . toBe ( 1 ) ;
96
+ expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
97
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
98
+ expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) Identicon.Image.__struct__/1 is undefined, cannot expand struct Identicon.Image' ) ;
99
+ expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathMix ) ;
100
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 11 , 4 ] , [ 11 , 30 ] ] ) ;
116
101
} ) ;
117
102
118
- it ( 'works with .exs files' , ( ) => {
119
- waitsForPromise ( ( ) =>
120
- atom . workspace . open ( exsFilePathMix ) . then ( editor => lint ( editor ) ) . then ( ( messages ) => {
121
- expect ( messages . length ) . toBe ( 1 ) ;
122
- expect ( messages [ 0 ] . severity ) . toBe ( 'warning' ) ;
123
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
124
- expect ( messages [ 0 ] . excerpt ) . toBe ( 'function simple_function/0 is unused' ) ;
125
- expect ( messages [ 0 ] . location . file ) . toBe ( exsFilePathMix ) ;
126
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 25 ] ] ) ;
127
- } ) ) ;
103
+ it ( 'works with .exs files' , async ( ) => {
104
+ const editor = await atom . workspace . open ( exsFilePathMix ) ;
105
+ const messages = await lint ( editor ) ;
106
+
107
+ expect ( messages . length ) . toBe ( 1 ) ;
108
+ expect ( messages [ 0 ] . severity ) . toBe ( 'warning' ) ;
109
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
110
+ expect ( messages [ 0 ] . excerpt ) . toBe ( 'function simple_function/0 is unused' ) ;
111
+ expect ( messages [ 0 ] . location . file ) . toBe ( exsFilePathMix ) ;
112
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 25 ] ] ) ;
128
113
} ) ;
129
114
} ) ;
130
115
} ) ;
131
- } ) ;
132
116
133
- describe ( 'when using the setting forceElixirc' , ( ) => {
134
- beforeEach ( ( ) => {
135
- atom . config . set ( 'linter-elixirc.forceElixirc' , true ) ;
136
- atom . workspace . destroyActivePaneItem ( ) ;
117
+ describe ( 'when using the setting forceElixirc' , ( ) => {
118
+ beforeEach ( async ( ) => {
119
+ atom . config . set ( 'linter-elixirc.forceElixirc' , true ) ;
120
+ } ) ;
137
121
138
- waitsForPromise ( ( ) =>
139
- Promise . all ( [
140
- atom . packages . activatePackage ( 'linter-elixirc' ) ,
141
- atom . packages . activatePackage ( 'language-elixir' ) ,
142
- ] ) ) ;
143
- } ) ;
122
+ it ( 'works with warnings' , async ( ) => {
123
+ const editor = await atom . workspace . open ( errorMode2PathMix ) ;
124
+ const messages = await lint ( editor ) ;
144
125
145
- it ( 'works with warnings' , ( ) => {
146
- waitsForPromise ( ( ) =>
147
- atom . workspace . open ( errorMode2PathMix ) . then ( editor => lint ( editor ) ) . then ( ( messages ) => {
148
- expect ( messages . length ) . toBe ( 1 ) ;
149
- expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
150
- expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
151
- expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) Identicon.Image.__struct__/1 is undefined, cannot expand struct Identicon.Image' ) ;
152
- expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathMix ) ;
153
- expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 11 , 4 ] , [ 11 , 30 ] ] ) ;
154
- } ) ) ;
126
+ expect ( messages . length ) . toBe ( 1 ) ;
127
+ expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
128
+ expect ( messages [ 0 ] . html ) . not . toBeDefined ( ) ;
129
+ expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) Identicon.Image.__struct__/1 is undefined, cannot expand struct Identicon.Image' ) ;
130
+ expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathMix ) ;
131
+ expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 11 , 4 ] , [ 11 , 30 ] ] ) ;
132
+ } ) ;
155
133
} ) ;
156
134
} ) ;
0 commit comments