Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import fm from '../' | ||
|
||
type Attributes = { | ||
title: string, | ||
description: string | ||
} | ||
|
||
const file = ` | ||
--- | ||
title: Just hack'n | ||
description: Nothing to see here | ||
--- | ||
This is some text about some stuff that happened sometime ago`; | ||
|
||
let nullBox: null; | ||
|
||
{ | ||
/* ===================== fm ===================== */ | ||
|
||
{ | ||
// THROWS 1 arguments, but got 0. | ||
fm() | ||
} | ||
|
||
{ | ||
// THROWS Argument of type 'null' is not assignable to parameter of type 'string'. | ||
fm(null) | ||
} | ||
|
||
{ | ||
|
||
// THROWS 'FrontMatterResult<unknown>' is not assignable to type 'null'. | ||
nullBox = fm(file); | ||
|
||
// THROWS 'FrontMatterResult<Attributes>' is not assignable to type 'null'. | ||
nullBox = fm<Attributes>(file); | ||
} | ||
|
||
{ | ||
|
||
let {attributes, body, bodyBegin, frontmatter} = fm<Attributes>(file); | ||
|
||
// THROWS Property 'foo' does not exist on type 'Attributes'. | ||
attributes.foo; | ||
|
||
// THROWS Type 'string' is not assignable to type 'null'. | ||
nullBox = body | ||
|
||
// THROWS Type 'number' is not assignable to type 'null'. | ||
nullBox = bodyBegin | ||
|
||
// THROWS Type 'string | undefined' is not assignable to type 'null'. | ||
nullBox = frontmatter | ||
} | ||
} | ||
|
||
{ | ||
/* ===================== fm.test ===================== */ | ||
|
||
{ | ||
// THROWS 1 arguments, but got 0. | ||
fm.test() | ||
} | ||
|
||
{ | ||
// THROWS Argument of type 'null' is not assignable to parameter of type 'string'. | ||
fm.test(null) | ||
} | ||
|
||
{ | ||
|
||
// THROWS Type 'boolean' is not assignable to type 'null'. | ||
nullBox = fm.test(file) | ||
} | ||
} | ||
|
||
console.log(nullBox); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import fm from '../' | ||
|
||
type Attributes = { | ||
title: string, | ||
description: string | ||
} | ||
|
||
const file = ` | ||
--- | ||
title: Just hack'n | ||
description: Nothing to see here | ||
--- | ||
This is some text about some stuff that happened sometime ago`; | ||
|
||
{ | ||
/* ===================== fm ===================== */ | ||
|
||
{ | ||
fm(file) | ||
} | ||
|
||
{ | ||
const { attributes, body, bodyBegin, frontmatter } = fm<Attributes>(file); | ||
console.log(attributes.title); | ||
console.log(attributes.description); | ||
console.log(body); | ||
console.log(bodyBegin); | ||
console.log(frontmatter); | ||
} | ||
} | ||
|
||
{ | ||
/* ===================== fm.test ===================== */ | ||
|
||
{ | ||
fm.test(file) | ||
} | ||
|
||
{ | ||
let resultTest: boolean; | ||
|
||
resultTest = fm.test(file); | ||
console.log(resultTest); | ||
} | ||
} |