@@ -2,52 +2,48 @@ var test = require('tape')
2
2
var remark = require ( 'remark' )
3
3
var find = require ( './index.js' )
4
4
5
- remark ( )
6
- . use ( function ( ) { return run } )
7
- . process ( 'Some _emphasis_, **strongness**, and `code`.' )
5
+ test ( 'unist-find' , function ( t ) {
6
+ var tree = remark ( ) . parse ( 'Some _emphasis_, **strongness**, and `code`.' )
8
7
9
- function run ( tree ) {
10
- test ( 'unist-find' , function ( t ) {
11
- t . throws ( function ( ) {
12
- find ( )
13
- } , 'should fail without tree' )
8
+ t . throws ( function ( ) {
9
+ find ( )
10
+ } , 'should fail without tree' )
14
11
15
- t . throws ( function ( ) {
16
- find ( tree )
17
- } , 'should fail without condition' )
12
+ t . throws ( function ( ) {
13
+ find ( tree )
14
+ } , 'should fail without condition' )
18
15
19
- t . test ( 'should find with string condition' , function ( st ) {
20
- var result = find ( tree , 'value' )
16
+ t . test ( 'should find with string condition' , function ( st ) {
17
+ var result = find ( tree , 'value' )
21
18
22
- st . equal ( result , tree . children [ 0 ] . children [ 0 ] )
19
+ st . equal ( result , tree . children [ 0 ] . children [ 0 ] )
23
20
24
- st . end ( )
25
- } )
21
+ st . end ( )
22
+ } )
26
23
27
- t . test ( 'should find with object condition' , function ( st ) {
28
- var result = find ( tree , { type : 'emphasis' } )
24
+ t . test ( 'should find with object condition' , function ( st ) {
25
+ var result = find ( tree , { type : 'emphasis' } )
29
26
30
- st . equal ( result , tree . children [ 0 ] . children [ 1 ] )
27
+ st . equal ( result , tree . children [ 0 ] . children [ 1 ] )
31
28
32
- st . end ( )
33
- } )
29
+ st . end ( )
30
+ } )
34
31
35
- t . test ( 'should find with function condition' , function ( st ) {
36
- var result = find ( tree , function ( node ) {
37
- return node . type === 'inlineCode'
38
- } )
32
+ t . test ( 'should find with function condition' , function ( st ) {
33
+ var result = find ( tree , function ( node ) {
34
+ return node . type === 'inlineCode'
35
+ } )
39
36
40
- st . equal ( result , tree . children [ 0 ] . children [ 5 ] )
37
+ st . equal ( result , tree . children [ 0 ] . children [ 5 ] )
41
38
42
- st . end ( )
43
- } )
39
+ st . end ( )
40
+ } )
44
41
45
- t . test ( 'should return undefined if no matches' , function ( st ) {
46
- var result = find ( tree , 'nope, nope, nope' )
42
+ t . test ( 'should return undefined if no matches' , function ( st ) {
43
+ var result = find ( tree , 'nope, nope, nope' )
47
44
48
- st . equal ( result , undefined )
45
+ st . equal ( result , undefined )
49
46
50
- st . end ( )
51
- } )
47
+ st . end ( )
52
48
} )
53
- }
49
+ } )
0 commit comments