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'
53
64var properties = {
75 position : {
@@ -19,8 +17,6 @@ var noPosition = {}
1917var generated = { line : null , column : null , offset : null }
2018
2119test ( 'unist-util-position' , function ( t ) {
22- var sides = [ 'start' , 'end' ]
23-
2420 t . test ( 'position' , function ( t ) {
2521 t . same (
2622 position ( properties ) ,
@@ -55,35 +51,60 @@ test('unist-util-position', function (t) {
5551 t . end ( )
5652 } )
5753
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+ } )
6283
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' )
6486
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+ )
7092
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+ )
7698
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+ )
82104
83- t . same ( fn ( ) , generated , 'should return an empty point without node' )
105+ t . same ( pointEnd ( ) , generated , 'should return an empty point without node' )
84106
85- t . end ( )
86- } )
107+ t . end ( )
87108 } )
88109
89110 t . end ( )
0 commit comments