1
- 'use strict'
2
-
3
- var test = require ( 'tape' )
4
- var position = require ( '.' )
1
+ import test from 'tape'
2
+ import { position , pointStart , pointEnd } from './index.js'
5
3
6
4
var properties = {
7
5
position : {
@@ -19,8 +17,6 @@ var noPosition = {}
19
17
var generated = { line : null , column : null , offset : null }
20
18
21
19
test ( 'unist-util-position' , function ( t ) {
22
- var sides = [ 'start' , 'end' ]
23
-
24
20
t . test ( 'position' , function ( t ) {
25
21
t . same (
26
22
position ( properties ) ,
@@ -55,35 +51,60 @@ test('unist-util-position', function (t) {
55
51
t . end ( )
56
52
} )
57
53
58
- // eslint-disable-next-line unicorn/no-array-for-each
59
- sides . forEach ( function ( side ) {
60
- t . test ( 'position.' + side , function ( t ) {
61
- var fn = position [ side ]
54
+ t . test ( 'pointStart' , function ( t ) {
55
+ t . same (
56
+ pointStart ( properties ) ,
57
+ properties . position . start ,
58
+ 'should get a side'
59
+ )
60
+
61
+ t . same (
62
+ pointStart ( noFields ) ,
63
+ generated ,
64
+ 'should return an empty point without fields'
65
+ )
66
+
67
+ t . same (
68
+ pointStart ( noPoints ) ,
69
+ generated ,
70
+ 'should return an empty point without points'
71
+ )
72
+
73
+ t . same (
74
+ pointStart ( noPosition ) ,
75
+ generated ,
76
+ 'should return an empty point without position'
77
+ )
78
+
79
+ t . same ( pointStart ( ) , generated , 'should return an empty point without node' )
80
+
81
+ t . end ( )
82
+ } )
62
83
63
- t . same ( fn ( properties ) , properties . position [ side ] , 'should get a side' )
84
+ t . test ( 'pointEnd' , function ( t ) {
85
+ t . same ( pointEnd ( properties ) , properties . position . end , 'should get a side' )
64
86
65
- t . same (
66
- fn ( noFields ) ,
67
- generated ,
68
- 'should return an empty point without fields'
69
- )
87
+ t . same (
88
+ pointEnd ( noFields ) ,
89
+ generated ,
90
+ 'should return an empty point without fields'
91
+ )
70
92
71
- t . same (
72
- fn ( noPoints ) ,
73
- generated ,
74
- 'should return an empty point without points'
75
- )
93
+ t . same (
94
+ pointEnd ( noPoints ) ,
95
+ generated ,
96
+ 'should return an empty point without points'
97
+ )
76
98
77
- t . same (
78
- fn ( noPosition ) ,
79
- generated ,
80
- 'should return an empty point without position'
81
- )
99
+ t . same (
100
+ pointEnd ( noPosition ) ,
101
+ generated ,
102
+ 'should return an empty point without position'
103
+ )
82
104
83
- t . same ( fn ( ) , generated , 'should return an empty point without node' )
105
+ t . same ( pointEnd ( ) , generated , 'should return an empty point without node' )
84
106
85
- t . end ( )
86
- } )
107
+ t . end ( )
87
108
} )
88
109
89
110
t . end ( )
0 commit comments