@@ -2,13 +2,36 @@ import { GithubBlog } from "../src/github-blog";
22
33const blog = new GithubBlog ( {
44 repo : "renatorib/github-blog-tests" ,
5- token : process . env . GITHUB_E2E_TESTS_TOKEN ! ,
5+ token : process . env . GITHUB_E2E_TESTS_TOKEN || process . env . GITHUB_TOKEN ! ,
66} ) ;
77
88describe ( "getPost" , ( ) => {
99 test ( "get post by slug" , async ( ) => {
1010 const result = await blog . getPost ( { query : { slug : "first-post" } } ) ;
1111
12+ expect ( result . post ?. number ) . toBe ( 1 ) ;
13+ expect ( result . post ?. title ) . toBe ( "First post" ) ;
14+ expect ( result . post ?. frontmatter ) . toStrictEqual ( { meta : "data" } ) ;
15+ expect ( result . post ?. body ) . toBe ( "\r\nHi" ) ;
16+ expect ( result . post ?. totalComments ) . toBeGreaterThan ( 0 ) ;
17+ expect ( result . post ?. totalReactions ) . toBeGreaterThan ( 0 ) ;
18+ expect ( result . post ?. reactions . THUMBS_UP ) . toBeGreaterThan ( 0 ) ;
19+ } ) ;
20+
21+ test ( "get post by id" , async ( ) => {
22+ const result = await blog . getPost ( { id : "MDU6SXNzdWU5MzYwOTEyMDc=" } ) ;
23+
24+ expect ( result . post ?. title ) . toBe ( "First post" ) ;
25+ expect ( result . post ?. frontmatter ) . toStrictEqual ( { meta : "data" } ) ;
26+ expect ( result . post ?. body ) . toBe ( "\r\nHi" ) ;
27+ expect ( result . post ?. totalComments ) . toBeGreaterThan ( 0 ) ;
28+ expect ( result . post ?. totalReactions ) . toBeGreaterThan ( 0 ) ;
29+ expect ( result . post ?. reactions . THUMBS_UP ) . toBeGreaterThan ( 0 ) ;
30+ } ) ;
31+
32+ test ( "get post by number" , async ( ) => {
33+ const result = await blog . getPost ( { number : 1 } ) ;
34+
1235 expect ( result . post ?. title ) . toBe ( "First post" ) ;
1336 expect ( result . post ?. frontmatter ) . toStrictEqual ( { meta : "data" } ) ;
1437 expect ( result . post ?. body ) . toBe ( "\r\nHi" ) ;
0 commit comments