@@ -2,7 +2,7 @@ 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" , ( ) => {
@@ -16,4 +16,26 @@ describe("getPost", () => {
1616 expect ( result . post ?. totalReactions ) . toBeGreaterThan ( 0 ) ;
1717 expect ( result . post ?. reactions . THUMBS_UP ) . toBeGreaterThan ( 0 ) ;
1818 } ) ;
19+
20+ test ( "get post by id" , async ( ) => {
21+ const result = await blog . getPost ( { id : "MDU6SXNzdWU5MzYwOTEyMDc=" } ) ;
22+
23+ expect ( result . post ?. title ) . toBe ( "First post" ) ;
24+ expect ( result . post ?. frontmatter ) . toStrictEqual ( { meta : "data" } ) ;
25+ expect ( result . post ?. body ) . toBe ( "\r\nHi" ) ;
26+ expect ( result . post ?. totalComments ) . toBeGreaterThan ( 0 ) ;
27+ expect ( result . post ?. totalReactions ) . toBeGreaterThan ( 0 ) ;
28+ expect ( result . post ?. reactions . THUMBS_UP ) . toBeGreaterThan ( 0 ) ;
29+ } ) ;
30+
31+ test ( "get post by number" , async ( ) => {
32+ const result = await blog . getPost ( { number : 1 } ) ;
33+
34+ expect ( result . post ?. title ) . toBe ( "First post" ) ;
35+ expect ( result . post ?. frontmatter ) . toStrictEqual ( { meta : "data" } ) ;
36+ expect ( result . post ?. body ) . toBe ( "\r\nHi" ) ;
37+ expect ( result . post ?. totalComments ) . toBeGreaterThan ( 0 ) ;
38+ expect ( result . post ?. totalReactions ) . toBeGreaterThan ( 0 ) ;
39+ expect ( result . post ?. reactions . THUMBS_UP ) . toBeGreaterThan ( 0 ) ;
40+ } ) ;
1941} ) ;
0 commit comments