1- var should = require ( "should" ) ;
2- var compareLocations = require ( "../lib/compareLocations" ) ;
3- var createLocation = function ( overides ) {
1+ "use strict" ;
2+
3+ const should = require ( "should" ) ;
4+ const compareLocations = require ( "../lib/compareLocations" ) ;
5+ const createLocation = function ( overides ) {
46 return Object . assign ( {
57 line : 10 ,
68 column : 5 ,
79 index : 3
810 } , overides ) ;
911} ;
1012
11- describe ( 'compareLocations' , function ( ) {
12- describe ( 'string location comparison' , function ( ) {
13- it ( 'returns -1 when the first string comes before the second string' , function ( ) {
14- compareLocations ( 'alpha' , 'beta' ) . should . be . exactly ( - 1 ) ;
15- } ) ;
13+ describe ( "compareLocations" , ( ) => {
14+ describe ( "string location comparison" , ( ) => {
15+ it ( "returns -1 when the first string comes before the second string" , ( ) =>
16+ compareLocations ( "alpha" , "beta" ) . should . be . exactly ( - 1 ) ) ;
1617
17- it ( 'returns 1 when the first string comes after the second string' , function ( ) {
18- compareLocations ( 'beta' , 'alpha' ) . should . be . exactly ( 1 ) ;
19- } ) ;
18+ it ( "returns 1 when the first string comes after the second string" , ( ) =>
19+ compareLocations ( "beta" , "alpha" ) . should . be . exactly ( 1 ) ) ;
2020
21- it ( 'returns 0 when the first string is the same as the second string' , function ( ) {
22- compareLocations ( 'charlie' , 'charlie' ) . should . be . exactly ( 0 ) ;
23- } ) ;
21+ it ( "returns 0 when the first string is the same as the second string" , ( ) =>
22+ compareLocations ( "charlie" , "charlie" ) . should . be . exactly ( 0 ) ) ;
2423 } ) ;
2524
26- describe ( ' object location comparison' , function ( ) {
27- var a , b ;
25+ describe ( " object location comparison" , ( ) => {
26+ let a , b ;
2827
29- describe ( ' location line number' , function ( ) {
30- beforeEach ( function ( ) {
28+ describe ( " location line number" , ( ) => {
29+ beforeEach ( ( ) => {
3130 a = createLocation ( {
3231 line : 10
3332 } ) ;
@@ -36,17 +35,15 @@ describe('compareLocations', function() {
3635 } ) ;
3736 } ) ;
3837
39- it ( 'returns -1 when the first location line number comes before the second location line number' , function ( ) {
40- compareLocations ( a , b ) . should . be . exactly ( - 1 ) ;
41- } ) ;
38+ it ( "returns -1 when the first location line number comes before the second location line number" , ( ) =>
39+ compareLocations ( a , b ) . should . be . exactly ( - 1 ) ) ;
4240
43- it ( 'returns 1 when the first location line number comes after the second location line number' , function ( ) {
44- compareLocations ( b , a ) . should . be . exactly ( 1 ) ;
45- } ) ;
41+ it ( "returns 1 when the first location line number comes after the second location line number" , ( ) =>
42+ compareLocations ( b , a ) . should . be . exactly ( 1 ) ) ;
4643 } ) ;
4744
48- describe ( ' location column number' , function ( ) {
49- beforeEach ( function ( ) {
45+ describe ( " location column number" , ( ) => {
46+ beforeEach ( ( ) => {
5047 a = createLocation ( {
5148 column : 10
5249 } ) ;
@@ -55,17 +52,15 @@ describe('compareLocations', function() {
5552 } ) ;
5653 } ) ;
5754
58- it ( 'returns -1 when the first location column number comes before the second location column number' , function ( ) {
59- compareLocations ( a , b ) . should . be . exactly ( - 1 ) ;
60- } ) ;
55+ it ( "returns -1 when the first location column number comes before the second location column number" , ( ) =>
56+ compareLocations ( a , b ) . should . be . exactly ( - 1 ) ) ;
6157
62- it ( 'returns 1 when the first location column number comes after the second location column number' , function ( ) {
63- compareLocations ( b , a ) . should . be . exactly ( 1 ) ;
64- } ) ;
58+ it ( "returns 1 when the first location column number comes after the second location column number" , ( ) =>
59+ compareLocations ( b , a ) . should . be . exactly ( 1 ) ) ;
6560 } ) ;
6661
67- describe ( ' location index number' , function ( ) {
68- beforeEach ( function ( ) {
62+ describe ( " location index number" , ( ) => {
63+ beforeEach ( ( ) => {
6964 a = createLocation ( {
7065 index : 10
7166 } ) ;
@@ -74,28 +69,26 @@ describe('compareLocations', function() {
7469 } ) ;
7570 } ) ;
7671
77- it ( 'returns -1 when the first location index number comes before the second location index number' , function ( ) {
78- compareLocations ( a , b ) . should . be . exactly ( - 1 ) ;
79- } ) ;
72+ it ( "returns -1 when the first location index number comes before the second location index number" , ( ) =>
73+ compareLocations ( a , b ) . should . be . exactly ( - 1 ) ) ;
8074
81- it ( 'returns 1 when the first location index number comes after the second location index number' , function ( ) {
82- compareLocations ( b , a ) . should . be . exactly ( 1 ) ;
83- } ) ;
75+ it ( "returns 1 when the first location index number comes after the second location index number" , ( ) =>
76+ compareLocations ( b , a ) . should . be . exactly ( 1 ) ) ;
8477 } ) ;
8578
86- describe ( ' same location' , function ( ) {
87- beforeEach ( function ( ) {
79+ describe ( " same location" , ( ) => {
80+ beforeEach ( ( ) => {
8881 a = createLocation ( ) ;
8982 b = createLocation ( ) ;
9083 } ) ;
9184
92- it ( ' returns 0' , function ( ) {
85+ it ( " returns 0" , ( ) => {
9386 compareLocations ( a , b ) . should . be . exactly ( 0 ) ;
9487 } ) ;
9588 } ) ;
9689
97- describe ( ' start location set' , function ( ) {
98- beforeEach ( function ( ) {
90+ describe ( " start location set" , ( ) => {
91+ beforeEach ( ( ) => {
9992 a = {
10093 start : createLocation ( {
10194 line : 10
@@ -108,45 +101,37 @@ describe('compareLocations', function() {
108101 } ;
109102 } ) ;
110103
111- it ( 'returns -1 when the first location line number comes before the second location line number' , function ( ) {
112- compareLocations ( a , b ) . should . be . exactly ( - 1 ) ;
113- } ) ;
104+ it ( "returns -1 when the first location line number comes before the second location line number" , ( ) =>
105+ compareLocations ( a , b ) . should . be . exactly ( - 1 ) ) ;
114106
115- it ( 'returns 1 when the first location line number comes after the second location line number' , function ( ) {
116- compareLocations ( b , a ) . should . be . exactly ( 1 ) ;
117- } ) ;
107+ it ( "returns 1 when the first location line number comes after the second location line number" , ( ) =>
108+ compareLocations ( b , a ) . should . be . exactly ( 1 ) ) ;
118109 } ) ;
119110 } ) ;
120111
121- describe ( 'string and object location comparison' , function ( ) {
122- it ( 'returns 1 when the first parameter is a string and the second parameter is an object' , function ( ) {
123- compareLocations ( 'alpha' , createLocation ( ) ) . should . be . exactly ( 1 ) ;
124- } ) ;
112+ describe ( "string and object location comparison" , ( ) => {
113+ it ( "returns 1 when the first parameter is a string and the second parameter is an object" , ( ) =>
114+ compareLocations ( "alpha" , createLocation ( ) ) . should . be . exactly ( 1 ) ) ;
125115
126- it ( 'returns -1 when the first parameter is an object and the second parameter is a string' , function ( ) {
127- compareLocations ( createLocation ( ) , 'alpha' ) . should . be . exactly ( - 1 ) ;
128- } ) ;
116+ it ( "returns -1 when the first parameter is an object and the second parameter is a string" , ( ) =>
117+ compareLocations ( createLocation ( ) , "alpha" ) . should . be . exactly ( - 1 ) ) ;
129118 } ) ;
130119
131- describe ( 'unknown location type comparison' , function ( ) {
132- it ( 'returns 0 when the first parameter is an object and the second parameter is a number' , function ( ) {
133- compareLocations ( createLocation ( ) , 123 ) . should . be . exactly ( 0 ) ;
134- } ) ;
120+ describe ( "unknown location type comparison" , ( ) => {
121+ it ( "returns 0 when the first parameter is an object and the second parameter is a number" , ( ) =>
122+ compareLocations ( createLocation ( ) , 123 ) . should . be . exactly ( 0 ) ) ;
135123
136- it ( 'returns undefined when the first parameter is a number and the second parameter is an object' , function ( ) {
137- should ( compareLocations ( 123 , createLocation ( ) ) ) . be . undefined ( ) ;
138- } ) ;
124+ it ( "returns undefined when the first parameter is a number and the second parameter is an object" , ( ) =>
125+ should ( compareLocations ( 123 , createLocation ( ) ) ) . be . undefined ( ) ) ;
139126
140- it ( 'returns 0 when the first parameter is a string and the second parameter is a number' , function ( ) {
141- compareLocations ( 'alpha' , 123 ) . should . be . exactly ( 0 ) ;
142- } ) ;
127+ it ( "returns 0 when the first parameter is a string and the second parameter is a number" , ( ) =>
128+ compareLocations ( "alpha" , 123 ) . should . be . exactly ( 0 ) ) ;
143129
144- it ( 'returns undefined when the first parameter is a number and the second parameter is a string' , function ( ) {
145- should ( compareLocations ( 123 , 'alpha' ) ) . be . undefined ( ) ;
146- } ) ;
130+ it ( "returns undefined when the first parameter is a number and the second parameter is a string" , ( ) =>
131+ should ( compareLocations ( 123 , "alpha" ) ) . be . undefined ( ) ) ;
132+
133+ it ( "returns undefined when both the first parameter and the second parameter is a number" , ( ) =>
134+ should ( compareLocations ( 123 , 456 ) ) . be . undefined ( ) ) ;
147135
148- it ( 'returns undefined when both the first parameter and the second parameter is a number' , function ( ) {
149- should ( compareLocations ( 123 , 456 ) ) . be . undefined ( ) ;
150- } ) ;
151136 } ) ;
152137} ) ;
0 commit comments