@@ -8,8 +8,8 @@ const NOW = new Date();
88
99describe ( 'resolveContentRef' , ( ) => {
1010 it ( 'should resolve a relative page ref' , async ( ) => {
11- const currentSpace = createMockSpace ( 'current-space' , 'Current Space' ) ;
12- const currentPages = [ createMockPage ( 'page-1' , 'Current Page' ) ] ;
11+ const currentSpace = createMockSpace ( { id : 'current-space' } ) ;
12+ const currentPages = [ createMockPage ( { id : 'page-1' } ) ] ;
1313 const context = createMockContext ( { space : currentSpace , pages : currentPages } ) ;
1414
1515 const result = await resolveContentRef (
@@ -26,8 +26,8 @@ describe('resolveContentRef', () => {
2626 } ) ;
2727
2828 it ( 'should resolve a url' , async ( ) => {
29- const currentSpace = createMockSpace ( 'current-space' , 'Current Space' ) ;
30- const currentPages = [ createMockPage ( 'page-1' , 'Current Page' ) ] ;
29+ const currentSpace = createMockSpace ( { id : 'current-space' } ) ;
30+ const currentPages = [ createMockPage ( { id : 'page-1' } ) ] ;
3131 const context = createMockContext ( { space : currentSpace , pages : currentPages } ) ;
3232
3333 const result = await resolveContentRef (
@@ -44,15 +44,14 @@ describe('resolveContentRef', () => {
4444 } ) ;
4545} ) ;
4646
47- const createMockSpace = ( id : string , title : string ) : api . Space => ( {
47+ const createMockSpace = ( space : MandateProps < Partial < api . Space > , 'id' > ) : api . Space => ( {
4848 object : 'space' ,
49- id,
50- title,
49+ title : 'My Space' ,
5150 visibility : api . ContentVisibility . Public ,
5251 urls : {
53- location : `https://api.gitbook.com/s/${ id } ` ,
54- published : `https://example.com/space/${ id } ` ,
55- app : `https://app.gitbook.com/s/${ id } ` ,
52+ location : `https://api.gitbook.com/s/${ space . id } ` ,
53+ published : `https://example.com/space/${ space . id } ` ,
54+ app : `https://app.gitbook.com/s/${ space . id } ` ,
5655 } ,
5756 organization : 'org-1' ,
5857 revision : 'rev-1' ,
@@ -75,17 +74,19 @@ const createMockSpace = (id: string, title: string): api.Space => ({
7574 merge : true ,
7675 review : true ,
7776 } ,
77+ ...space ,
7878} ) ;
7979
80- const createMockPage = ( id : string , title : string ) : api . RevisionPage => ( {
81- id,
82- title,
83- slug : title . toLowerCase ( ) . replace ( / \s + / g, '-' ) ,
80+ const createMockPage = (
81+ page : MandateProps < Partial < api . RevisionPageDocument > , 'id' >
82+ ) : api . RevisionPageDocument => ( {
83+ title : 'Page 1' ,
84+ slug : 'page-1' ,
8485 kind : 'sheet' ,
8586 type : 'document' ,
8687 layout : { } ,
8788 urls : {
88- app : `https://app.gitbook.com/s/${ id } /page-1` ,
89+ app : `https://app.gitbook.com/s/${ page . id } /page-1` ,
8990 } ,
9091 path : '/page-1' ,
9192 pages : [ ] ,
@@ -94,6 +95,7 @@ const createMockPage = (id: string, title: string): api.RevisionPage => ({
9495 data : { } ,
9596 nodes : [ ] ,
9697 } ,
98+ ...page ,
9799} ) ;
98100
99101const createMockContext = (
0 commit comments