1
1
'use babel' ;
2
2
3
3
import * as path 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 badPath = path . join ( __dirname , 'fixtures' , 'bad.css' ) ;
6
8
const goodPath = path . join ( __dirname , 'fixtures' , 'good.css' ) ;
@@ -12,105 +14,62 @@ const projectBadPath = path.join(projectPath, 'files', 'badWC.css');
12
14
describe ( 'The csslint provider for Linter' , ( ) => {
13
15
const lint = require ( '../lib/main.js' ) . provideLinter ( ) . lint ;
14
16
15
- beforeEach ( ( ) => {
17
+ beforeEach ( async ( ) => {
16
18
atom . workspace . destroyActivePaneItem ( ) ;
17
- waitsForPromise ( ( ) =>
18
- Promise . all ( [
19
- atom . packages . activatePackage ( 'linter-csslint' ) ,
20
- atom . packages . activatePackage ( 'language-css' ) ,
21
- ] ) . then ( ( ) =>
22
- atom . workspace . open ( goodPath ) ,
23
- ) ,
24
- ) ;
19
+
20
+ await atom . packages . activatePackage ( 'linter-csslint' ) ;
21
+ await atom . packages . activatePackage ( 'language-css' ) ;
25
22
} ) ;
26
23
27
24
describe ( 'checks bad.css and' , ( ) => {
28
- let editor = null ;
29
- beforeEach ( ( ) =>
30
- waitsForPromise ( ( ) =>
31
- atom . workspace . open ( badPath ) . then ( ( openEditor ) => { editor = openEditor ; } ) ,
32
- ) ,
33
- ) ;
34
-
35
- it ( 'finds at least one message' , ( ) =>
36
- waitsForPromise ( ( ) =>
37
- lint ( editor ) . then ( messages =>
38
- expect ( messages . length ) . toBeGreaterThan ( 0 ) ,
39
- ) ,
40
- ) ,
41
- ) ;
25
+ it ( 'verifies the first message' , async ( ) => {
26
+ const editor = await atom . workspace . open ( badPath ) ;
27
+ const messages = await lint ( editor ) ;
42
28
43
- it ( 'verifies the first message' , ( ) =>
44
- waitsForPromise ( ( ) =>
45
- lint ( editor ) . then ( ( messages ) => {
46
- expect ( messages [ 0 ] . type ) . toBe ( 'Warning' ) ;
47
- expect ( messages [ 0 ] . text ) . toBe ( 'Rule is empty.' ) ;
48
- expect ( messages [ 0 ] . filePath ) . toBe ( badPath ) ;
49
- expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 0 ] , [ 0 , 4 ] ] ) ;
50
- } ) ,
51
- ) ,
52
- ) ;
29
+ expect ( messages . length ) . toBe ( 1 ) ;
30
+ expect ( messages [ 0 ] . type ) . toBe ( 'Warning' ) ;
31
+ expect ( messages [ 0 ] . text ) . toBe ( 'Rule is empty.' ) ;
32
+ expect ( messages [ 0 ] . filePath ) . toBe ( badPath ) ;
33
+ expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 0 ] , [ 0 , 4 ] ] ) ;
34
+ } ) ;
53
35
} ) ;
54
36
55
37
describe ( 'warns on invalid CSS' , ( ) => {
56
- let editor = null ;
57
- beforeEach ( ( ) =>
58
- waitsForPromise ( ( ) =>
59
- atom . workspace . open ( invalidPath ) . then ( ( openEditor ) => { editor = openEditor ; } ) ,
60
- ) ,
61
- ) ;
38
+ it ( 'verifies the message' , async ( ) => {
39
+ const editor = await atom . workspace . open ( invalidPath ) ;
40
+ const messages = await lint ( editor ) ;
41
+
42
+ expect ( messages . length ) . toBe ( 1 ) ;
43
+ expect ( messages [ 0 ] . type ) . toBe ( 'Error' ) ;
44
+ expect ( messages [ 0 ] . text ) . toBe ( 'Unexpected token \'}\' at line 1, col 1.' ) ;
45
+ expect ( messages [ 0 ] . filePath ) . toBe ( invalidPath ) ;
46
+ expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 0 ] , [ 0 , 1 ] ] ) ;
47
+ } ) ;
48
+ } ) ;
62
49
63
- it ( 'finds one message' , ( ) =>
64
- waitsForPromise ( ( ) =>
65
- lint ( editor ) . then ( messages =>
66
- expect ( messages . length ) . toBe ( 1 ) ,
67
- ) ,
68
- ) ,
69
- ) ;
50
+ it ( 'finds nothing wrong with a valid file' , async ( ) => {
51
+ const editor = await atom . workspace . open ( goodPath ) ;
52
+ const messages = await lint ( editor ) ;
70
53
71
- it ( 'verifies the message' , ( ) =>
72
- waitsForPromise ( ( ) =>
73
- lint ( editor ) . then ( ( messages ) => {
74
- expect ( messages [ 0 ] . type ) . toBe ( 'Error' ) ;
75
- expect ( messages [ 0 ] . text ) . toBe ( 'Unexpected token \'}\' at line 1, col 1.' ) ;
76
- expect ( messages [ 0 ] . filePath ) . toBe ( invalidPath ) ;
77
- expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 0 ] , [ 0 , 1 ] ] ) ;
78
- } ) ,
79
- ) ,
80
- ) ;
54
+ expect ( messages . length ) . toEqual ( 0 ) ;
81
55
} ) ;
82
56
83
- it ( 'finds nothing wrong with a valid file' , ( ) =>
84
- waitsForPromise ( ( ) =>
85
- atom . workspace . open ( goodPath ) . then ( editor =>
86
- lint ( editor ) . then ( messages =>
87
- expect ( messages . length ) . toEqual ( 0 ) ,
88
- ) ,
89
- ) ,
90
- ) ,
91
- ) ;
57
+ it ( 'handles an empty file' , async ( ) => {
58
+ const editor = await atom . workspace . open ( emptyPath ) ;
59
+ const messages = await lint ( editor ) ;
92
60
93
- it ( 'handles an empty file' , ( ) =>
94
- waitsForPromise ( ( ) =>
95
- atom . workspace . open ( emptyPath ) . then ( editor =>
96
- lint ( editor ) . then ( messages =>
97
- expect ( messages . length ) . toEqual ( 0 ) ,
98
- ) ,
99
- ) ,
100
- ) ,
101
- ) ;
61
+ expect ( messages . length ) . toEqual ( 0 ) ;
62
+ } ) ;
102
63
103
- it ( 'respects .csslintrc configurations at the project root' , ( ) => {
64
+ it ( 'respects .csslintrc configurations at the project root' , async ( ) => {
104
65
atom . project . addPath ( projectPath ) ;
105
- waitsForPromise ( ( ) =>
106
- atom . workspace . open ( projectBadPath ) . then ( editor =>
107
- lint ( editor ) . then ( ( messages ) => {
108
- expect ( messages [ 0 ] . type ) . toBeDefined ( ) ;
109
- expect ( messages [ 0 ] . type ) . toEqual ( 'Error' ) ;
110
- expect ( messages [ 0 ] . text ) . toBeDefined ( ) ;
111
- expect ( messages [ 0 ] . text ) . toEqual ( 'Rule is empty.' ) ;
112
- } ) ,
113
- ) ,
114
- ) ;
66
+ const editor = await atom . workspace . open ( projectBadPath ) ;
67
+ const messages = await lint ( editor ) ;
68
+
69
+ expect ( messages . length ) . toBe ( 1 ) ;
70
+ expect ( messages [ 0 ] . type ) . toBeDefined ( ) ;
71
+ expect ( messages [ 0 ] . type ) . toEqual ( 'Error' ) ;
72
+ expect ( messages [ 0 ] . text ) . toBeDefined ( ) ;
73
+ expect ( messages [ 0 ] . text ) . toEqual ( 'Rule is empty.' ) ;
115
74
} ) ;
116
75
} ) ;
0 commit comments