1
- 'use strict'
2
-
3
- var test = require ( 'tape' )
4
- var stringify = require ( '.' )
1
+ import test from 'tape'
2
+ import { stringifyPosition } from './index.js'
5
3
6
4
test ( 'stringifyPosition' , function ( t ) {
7
- t . equal ( stringify ( ) , '' , 'should return empty `string` with `undefined`' )
8
- t . equal ( stringify ( null ) , '' , 'should return empty `string` with `null`' )
9
- t . equal ( stringify ( 'foo' ) , '' , 'should return empty `string` with `string`' )
10
- t . equal ( stringify ( 5 ) , '' , 'should return empty `string` with `number`' )
11
- t . equal ( stringify ( { } ) , '' , 'should return empty `string` with `{}`' )
5
+ t . equal (
6
+ stringifyPosition ( ) ,
7
+ '' ,
8
+ 'should return empty `string` with `undefined`'
9
+ )
10
+ t . equal (
11
+ stringifyPosition ( null ) ,
12
+ '' ,
13
+ 'should return empty `string` with `null`'
14
+ )
15
+ t . equal (
16
+ stringifyPosition ( 'foo' ) ,
17
+ '' ,
18
+ 'should return empty `string` with `string`'
19
+ )
20
+ t . equal (
21
+ stringifyPosition ( 5 ) ,
22
+ '' ,
23
+ 'should return empty `string` with `number`'
24
+ )
25
+ t . equal ( stringifyPosition ( { } ) , '' , 'should return empty `string` with `{}`' )
12
26
13
27
t . equal (
14
- stringify ( { type : 'text' } ) ,
28
+ stringifyPosition ( { type : 'text' } ) ,
15
29
'1:1-1:1' ,
16
30
'should return a range for a `node` without `position`'
17
31
)
18
32
19
33
t . equal (
20
- stringify ( { type : 'text' , position : 3 } ) ,
34
+ stringifyPosition ( { type : 'text' , position : 3 } ) ,
21
35
'1:1-1:1' ,
22
36
'should return a range for `node` with invalid `position` #1'
23
37
)
24
38
25
39
t . equal (
26
- stringify ( {
40
+ stringifyPosition ( {
27
41
type : 'text' ,
28
42
position : { start : { } , end : { } }
29
43
} ) ,
@@ -32,7 +46,7 @@ test('stringifyPosition', function (t) {
32
46
)
33
47
34
48
t . equal (
35
- stringify ( {
49
+ stringifyPosition ( {
36
50
type : 'text' ,
37
51
position : {
38
52
start : { line : null , column : null } ,
@@ -44,7 +58,7 @@ test('stringifyPosition', function (t) {
44
58
)
45
59
46
60
t . equal (
47
- stringify ( {
61
+ stringifyPosition ( {
48
62
type : 'text' ,
49
63
position : {
50
64
start : { line : 2 , column : 5 } ,
@@ -56,25 +70,25 @@ test('stringifyPosition', function (t) {
56
70
)
57
71
58
72
t . equal (
59
- stringify ( { start : null , end : null } ) ,
73
+ stringifyPosition ( { start : null , end : null } ) ,
60
74
'1:1-1:1' ,
61
75
'should return a range for a `position` without `point`s'
62
76
)
63
77
64
78
t . equal (
65
- stringify ( { start : 3 , end : 6 } ) ,
79
+ stringifyPosition ( { start : 3 , end : 6 } ) ,
66
80
'1:1-1:1' ,
67
81
'should return a range for `position` with invalid `point`s #1'
68
82
)
69
83
70
84
t . equal (
71
- stringify ( { start : { } , end : { } } ) ,
85
+ stringifyPosition ( { start : { } , end : { } } ) ,
72
86
'1:1-1:1' ,
73
87
'should return range for `position` with invalid `point`s #1'
74
88
)
75
89
76
90
t . equal (
77
- stringify ( {
91
+ stringifyPosition ( {
78
92
start : { line : null , column : null } ,
79
93
end : { line : null , column : null }
80
94
} ) ,
@@ -83,7 +97,7 @@ test('stringifyPosition', function (t) {
83
97
)
84
98
85
99
t . equal (
86
- stringify ( {
100
+ stringifyPosition ( {
87
101
start : { line : 2 , column : 5 } ,
88
102
end : { line : 2 , column : 6 }
89
103
} ) ,
@@ -92,31 +106,31 @@ test('stringifyPosition', function (t) {
92
106
)
93
107
94
108
t . equal (
95
- stringify ( { line : null , column : null } ) ,
109
+ stringifyPosition ( { line : null , column : null } ) ,
96
110
'1:1' ,
97
111
'should return a point for a `point` without indices'
98
112
)
99
113
100
114
t . equal (
101
- stringify ( { line : 'foo' , column : 'bar' } ) ,
115
+ stringifyPosition ( { line : 'foo' , column : 'bar' } ) ,
102
116
'1:1' ,
103
117
'should return a point for a `point` with invalid indices #1'
104
118
)
105
119
106
120
t . equal (
107
- stringify ( { line : 4 } ) ,
121
+ stringifyPosition ( { line : 4 } ) ,
108
122
'4:1' ,
109
123
'should return a point for a partially valid `point` #1'
110
124
)
111
125
112
126
t . equal (
113
- stringify ( { column : 12 } ) ,
127
+ stringifyPosition ( { column : 12 } ) ,
114
128
'1:12' ,
115
129
'should return a point for a partially valid `point` #1'
116
130
)
117
131
118
132
t . equal (
119
- stringify ( { line : 5 , column : 2 } ) ,
133
+ stringifyPosition ( { line : 5 , column : 2 } ) ,
120
134
'5:2' ,
121
135
'should return a point for a valid `point`'
122
136
)
0 commit comments