@@ -194,16 +194,63 @@ describe('enhancer', () => {
194
194
} )
195
195
} )
196
196
197
+ describe ( 'public api' , ( ) => {
198
+ test ( 'dirname' , async ( ) => {
199
+ const dirname = 'docs'
200
+ const { relative, filePath } = getDocument ( 'README.md' )
201
+ const markdown = getMarkdown ( )
202
+ const page = await setupPage ( { filePath, relative } , { markdown } )
203
+ expect ( page . dirname ) . toBe ( dirname )
204
+ } )
205
+
206
+ test ( 'filename' , async ( ) => {
207
+ const filename = 'README'
208
+ const { relative, filePath } = getDocument ( `${ filename } .md` )
209
+ const markdown = getMarkdown ( )
210
+ const page = await setupPage ( { filePath, relative } , { markdown } )
211
+ expect ( page . filename ) . toBe ( filename )
212
+ } )
213
+
214
+ test ( 'slug' , async ( ) => {
215
+ const markdown = getMarkdown ( )
216
+ const dirname = 'docs'
217
+ const indexPageFixture = getDocument ( 'README.md' )
218
+ const indexPage = await setupPage (
219
+ { filePath : indexPageFixture . filePath , relative : indexPageFixture . relative } , { markdown }
220
+ )
221
+ expect ( indexPage . slug ) . toBe ( dirname )
222
+
223
+ const filename = 'alpha'
224
+ const pageFixture = getDocument ( `${ filename } .md` )
225
+ const page = await setupPage (
226
+ { filePath : pageFixture . filePath , relative : pageFixture . relative } , { markdown }
227
+ )
228
+ expect ( page . slug ) . toBe ( filename )
229
+ } )
230
+
231
+ test ( 'strippedFilename' , async ( ) => {
232
+ const { relative, filePath } = getDocument ( '2020-01-01-date.md' )
233
+ const markdown = getMarkdown ( )
234
+ const page = await setupPage ( { filePath, relative } , { markdown } )
235
+ expect ( page . strippedFilename ) . toBe ( 'date' )
236
+ } )
237
+
238
+ test ( 'date' , async ( ) => {
239
+ const frontmatter = { date : '2020-01-01' }
240
+ const dateInFrontmatterPage = await setupPage ( { path : '/' , frontmatter } )
241
+ expect ( dateInFrontmatterPage . date ) . toBe ( '2020-01-01' )
242
+
243
+ const { relative, filePath } = getDocument ( '2020-01-01-date.md' )
244
+ const markdown = getMarkdown ( )
245
+ const dateInPathPage = await setupPage ( { filePath, relative } , { markdown } )
246
+ expect ( dateInPathPage . date ) . toBe ( '2020-01-01' )
247
+ } )
248
+ } )
249
+
197
250
// TODO permalink - driven by global pattern
198
251
// TODO I18n
199
- // TODO Meta
200
252
// TODO Add a page with explicit content
201
253
// TODO Excerpt
202
254
// TODO SFC
203
255
// TODO Headers
204
256
205
- // TODO get date
206
- // TODO get strippedFilename
207
- // TODO get slug
208
- // TODO get filename
209
- // TODO get dirname
0 commit comments