File tree Expand file tree Collapse file tree 2 files changed +93
-0
lines changed
Expand file tree Collapse file tree 2 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 1+ export const snapshot = {};
2+
3+ snapshot [` extractFromCodeTitle() > accurate titles > "code:foo.extA(extB)" 1` ] = `
4+ {
5+ filename : " foo.extA" ,
6+ indent : 0 ,
7+ lang : " extB" ,
8+ }
9+ ` ;
10+
11+ snapshot [` extractFromCodeTitle() > accurate titles > " code:foo.extA(extB)" 1` ] = `
12+ {
13+ filename : " foo.extA" ,
14+ indent : 1 ,
15+ lang : " extB" ,
16+ }
17+ ` ;
18+
19+ snapshot [` extractFromCodeTitle() > accurate titles > " code: foo.extA (extB)" 1` ] = `
20+ {
21+ filename : " foo.extA" ,
22+ indent : 2 ,
23+ lang : " extB" ,
24+ }
25+ ` ;
26+
27+ snapshot [` extractFromCodeTitle() > accurate titles > " code: foo (extB) " 1` ] = `
28+ {
29+ filename : " foo" ,
30+ indent : 2 ,
31+ lang : " extB" ,
32+ }
33+ ` ;
34+
35+ snapshot [` extractFromCodeTitle() > accurate titles > " code: foo.extA " 1` ] = `
36+ {
37+ filename : " foo.extA" ,
38+ indent : 2 ,
39+ lang : " extA" ,
40+ }
41+ ` ;
42+
43+ snapshot [` extractFromCodeTitle() > accurate titles > " code: foo " 1` ] = `
44+ {
45+ filename : " foo" ,
46+ indent : 2 ,
47+ lang : " foo" ,
48+ }
49+ ` ;
50+
51+ snapshot [` extractFromCodeTitle() > accurate titles > " code: .foo " 1` ] = `
52+ {
53+ filename : " .foo" ,
54+ indent : 2 ,
55+ lang : " .foo" ,
56+ }
57+ ` ;
Original file line number Diff line number Diff line change 1+ /// <reference lib="deno.ns" />
2+
3+ import { assertEquals , assertSnapshot } from "../../deps/testing.ts" ;
4+ import { extractFromCodeTitle } from "./_codeBlock.ts" ;
5+
6+ Deno . test ( "extractFromCodeTitle()" , async ( t ) => {
7+ await t . step ( "accurate titles" , async ( st ) => {
8+ const titles = [
9+ "code:foo.extA(extB)" ,
10+ " code:foo.extA(extB)" ,
11+ " code: foo.extA (extB)" ,
12+ " code: foo (extB) " ,
13+ " code: foo.extA " ,
14+ " code: foo " ,
15+ " code: .foo " ,
16+ ] ;
17+ for ( const title of titles ) {
18+ await st . step ( `"${ title } "` , async ( sst ) => {
19+ await assertSnapshot ( sst , extractFromCodeTitle ( title ) ) ;
20+ } ) ;
21+ }
22+ } ) ;
23+
24+ await t . step ( "inaccurate titles" , async ( st ) => {
25+ const nonTitles = [
26+ " code: foo. " , // コードブロックにはならないので`null`が正常
27+ "any:code: foo " ,
28+ " I'm not code block " ,
29+ ] ;
30+ for ( const title of nonTitles ) {
31+ await st . step ( `"${ title } "` , async ( ) => {
32+ await assertEquals ( null , extractFromCodeTitle ( title ) ) ;
33+ } ) ;
34+ }
35+ } ) ;
36+ } ) ;
You can’t perform that action at this time.
0 commit comments