1
1
import fs from 'fs'
2
2
import path from 'path'
3
3
import test from 'tape'
4
- import vfile from 'to-vfile'
5
- import unified from 'unified'
6
- import remark from 'remark'
7
- import not from 'not'
8
- import hidden from 'is-hidden'
9
- import frontmatter from '../index.js'
4
+ import { readSync } from 'to-vfile'
5
+ import { unified } from 'unified'
6
+ import { remark } from 'remark'
7
+ import { isHidden } from 'is-hidden'
8
+ import remarkFrontmatter from '../index.js'
10
9
11
10
var join = path . join
12
11
var read = fs . readFileSync
13
12
var write = fs . writeFileSync
14
13
var dir = fs . readdirSync
15
14
16
- test ( 'frontmatter()' , function ( t ) {
17
- t . equal ( typeof frontmatter , 'function' , 'should be a function' )
18
-
15
+ test ( 'remarkFrontmatter' , function ( t ) {
19
16
t . doesNotThrow ( function ( ) {
20
- remark ( ) . use ( frontmatter ) . freeze ( )
17
+ remark ( ) . use ( remarkFrontmatter ) . freeze ( )
21
18
} , 'should not throw if not passed options' )
22
19
23
20
t . doesNotThrow ( function ( ) {
24
- unified ( ) . use ( frontmatter ) . freeze ( )
21
+ unified ( ) . use ( remarkFrontmatter ) . freeze ( )
25
22
} , 'should not throw if without parser or compiler' )
26
23
27
24
t . throws (
28
25
function ( ) {
29
- unified ( ) . use ( frontmatter , [ 1 ] ) . freeze ( )
26
+ unified ( ) . use ( remarkFrontmatter , [ 1 ] ) . freeze ( )
30
27
} ,
31
28
/ ^ E r r o r : E x p e c t e d m a t t e r t o b e a n o b j e c t , n o t ` 1 ` / ,
32
29
'should throw if not given a preset or a matter'
33
30
)
34
31
35
32
t . throws (
36
33
function ( ) {
37
- unified ( ) . use ( frontmatter , [ 'jsonml' ] ) . freeze ( )
34
+ unified ( ) . use ( remarkFrontmatter , [ 'jsonml' ] ) . freeze ( )
38
35
} ,
39
36
/ ^ E r r o r : M i s s i n g m a t t e r d e f i n i t i o n f o r ` j s o n m l ` / ,
40
37
'should throw if given an unknown preset'
@@ -43,7 +40,7 @@ test('frontmatter()', function (t) {
43
40
t . throws (
44
41
function ( ) {
45
42
unified ( )
46
- . use ( frontmatter , [ { marker : '*' } ] )
43
+ . use ( remarkFrontmatter , [ { marker : '*' } ] )
47
44
. freeze ( )
48
45
} ,
49
46
/ ^ E r r o r : M i s s i n g ` t y p e ` i n m a t t e r ` { " m a r k e r " : " \* " } ` / ,
@@ -53,7 +50,7 @@ test('frontmatter()', function (t) {
53
50
t . throws (
54
51
function ( ) {
55
52
unified ( )
56
- . use ( frontmatter , [ { type : 'jsonml' } ] )
53
+ . use ( remarkFrontmatter , [ { type : 'jsonml' } ] )
57
54
. freeze ( )
58
55
} ,
59
56
/ ^ E r r o r : M i s s i n g ` m a r k e r ` o r ` f e n c e ` i n m a t t e r ` { " t y p e " : " j s o n m l " } ` / ,
@@ -65,15 +62,15 @@ test('frontmatter()', function (t) {
65
62
66
63
test ( 'fixtures' , function ( t ) {
67
64
var base = join ( 'test' , 'fixtures' )
68
- var entries = dir ( base ) . filter ( not ( hidden ) )
65
+ var entries = dir ( base ) . filter ( ( d ) => ! isHidden ( d ) )
69
66
70
67
t . plan ( entries . length )
71
68
72
69
entries . forEach ( each )
73
70
74
71
function each ( fixture ) {
75
72
t . test ( fixture , function ( st ) {
76
- var input = vfile . readSync ( join ( base , fixture , 'input.md' ) )
73
+ var input = readSync ( join ( base , fixture , 'input.md' ) )
77
74
var treePath = join ( base , fixture , 'tree.json' )
78
75
var outputPath = join ( base , fixture , 'output.md' )
79
76
var output
@@ -86,7 +83,7 @@ test('fixtures', function (t) {
86
83
config = JSON . parse ( read ( join ( base , fixture , 'config.json' ) ) )
87
84
} catch ( _ ) { }
88
85
89
- proc = remark ( ) . use ( frontmatter , config )
86
+ proc = remark ( ) . use ( remarkFrontmatter , config )
90
87
actual = JSON . parse ( JSON . stringify ( proc . parse ( input ) ) )
91
88
92
89
try {
0 commit comments