@@ -13,7 +13,36 @@ describe('The lesshint provider for Linter', () => {
13
13
} ) ;
14
14
} ) ;
15
15
16
+ describe ( 'lesshint-breaking files checks' , ( ) => {
17
+ let editor ;
18
+
19
+ beforeEach ( ( ) => {
20
+ waitsForPromise ( ( ) => {
21
+ return atom . workspace . open ( `${ __dirname } /fixtures/lesshint-breaker.less` ) . then ( ( openEditor ) => {
22
+ editor = openEditor ;
23
+ } ) ;
24
+ } ) ;
25
+ } ) ;
26
+
27
+ it ( 'fails file that breaks lesshint' , ( ) => {
28
+ waitsForPromise ( ( ) => {
29
+
30
+ const priorNotificationsCount = atom . notifications . getNotifications ( ) . length ;
31
+
32
+ return lint ( editor ) . then ( ( ) => {
33
+
34
+ const notifications = atom . notifications . getNotifications ( ) ;
35
+
36
+ expect ( notifications [ priorNotificationsCount ] . getType ( ) ) . toEqual ( 'error' ) ;
37
+ expect ( notifications [ priorNotificationsCount ] . getMessage ( ) ) . toEqual ( 'lesshint couldn\'t check this file.' ) ;
38
+ } ) ;
39
+ } ) ;
40
+ } ) ;
41
+ } ) ;
42
+
16
43
describe ( 'invalid files checks' , ( ) => {
44
+ const Range = require ( 'atom' ) . Range ;
45
+
17
46
let editor ;
18
47
19
48
beforeEach ( ( ) => {
@@ -28,16 +57,16 @@ describe('The lesshint provider for Linter', () => {
28
57
const errorName = 'emptyRule' ;
29
58
const errorMessage = "There shouldn't be any empty rules present." ;
30
59
31
- lint ( editor ) . then ( ( messages ) => {
32
- expect ( messages [ 0 ] . type ) . toBeDefined ( ) ;
33
- expect ( messages [ 0 ] . type ) . toEqual ( 'warning' ) ;
34
- expect ( messages [ 0 ] . html ) . toBeDefined ( ) ;
35
- expect ( messages [ 0 ] . html ) . toEqual ( `<span class='badge badge-flexible'> ${ errorName } </span> ${ errorMessage } ` ) ;
36
- expect ( messages [ 0 ] . filePath ) . toBeDefined ( ) ;
37
- expect ( messages [ 0 ] . filePath ) . toMatch ( / . + i n v a l i d \. l e s s $ / ) ;
38
- expect ( messages [ 0 ] . range ) . toBeDefined ( ) ;
39
- expect ( messages [ 0 ] . range . length ) . toEqual ( 2 ) ;
40
- expect ( messages [ 0 ] . range ) . toEqual ( [ [ 1 , 0 ] , [ 1 , 4 ] ] ) ;
60
+ waitsForPromise ( ( ) => {
61
+ return lint ( editor ) . then ( ( messages ) => {
62
+ expect ( messages [ 0 ] . type ) . toBeDefined ( ) ;
63
+ expect ( messages [ 0 ] . type ) . toEqual ( 'warning' ) ;
64
+ expect ( messages [ 0 ] . html ) . toBeDefined ( ) ;
65
+ expect ( messages [ 0 ] . html ) . toEqual ( `<span class='badge badge-flexible'> ${ errorName } </span> ${ errorMessage } ` ) ;
66
+ expect ( messages [ 0 ] . filePath ) . toBeDefined ( ) ;
67
+ expect ( messages [ 0 ] . filePath ) . toMatch ( / . + i n v a l i d \. l e s s $ / ) ;
68
+ expect ( messages [ 0 ] . range ) . toEqual ( new Range ( [ 1 , 0 ] , [ 1 , 4 ] ) ) ;
69
+ } ) ;
41
70
} ) ;
42
71
} ) ;
43
72
} ) ;
@@ -54,8 +83,10 @@ describe('The lesshint provider for Linter', () => {
54
83
} ) ;
55
84
56
85
it ( 'allows file without errors' , ( ) => {
57
- lint ( editor ) . then ( ( messages ) => {
58
- expect ( messages . length ) . toEqual ( 0 ) ;
86
+ waitsForPromise ( ( ) => {
87
+ return lint ( editor ) . then ( ( messages ) => {
88
+ expect ( messages . length ) . toEqual ( 0 ) ;
89
+ } ) ;
59
90
} ) ;
60
91
} ) ;
61
92
} ) ;
@@ -74,8 +105,10 @@ describe('The lesshint provider for Linter', () => {
74
105
} ) ;
75
106
76
107
it ( 'should not check anything when "onlyWithRc" is true and no ".lesshintrc" is found' , ( ) => {
77
- lint ( editor ) . then ( ( messages ) => {
78
- expect ( messages . length ) . toEqual ( 0 ) ;
108
+ waitsForPromise ( ( ) => {
109
+ return lint ( editor ) . then ( ( messages ) => {
110
+ expect ( messages . length ) . toEqual ( 0 ) ;
111
+ } ) ;
79
112
} ) ;
80
113
} ) ;
81
114
} ) ;
0 commit comments