@@ -17,6 +17,10 @@ const newArticle = {
1717 slug : 'new-title' ,
1818 image_url : 'http://placekitten.com/400/400' ,
1919 summary : 'the summary' ,
20+ html_content : 'the content' ,
21+ author : 1 ,
22+ category : 1 ,
23+ related_articles : [ 1 , 2 ] ,
2024} ;
2125
2226describe ( 'Articles Controller' , ( ) => {
@@ -38,49 +42,49 @@ describe('Articles Controller', () => {
3842 // expect(articles.length).toBeGreaterThan(0);
3943 // });
4044
41- // test('getArticle should return an article with content', async () => {
42- // expect.assertions(13 );
43- // const article = await getArticle(1);
44- // expect(typeof article.id).toBe('number');
45- // expect(typeof article.title).toBe('string');
46- // expect(typeof article.subtitle).toBe('string');
47- // expect(typeof article.slug).toBe('string');
48- // expect(typeof article.posted_on).toBe('string' );
49- // expect(typeof article.article_image_url).toBe('string');
50- // expect(typeof article.summary).toBe('string');
51- // expect(typeof article.html_content).toBe('string');
52- // expect(typeof article.author_name).toBe('string');
53- // expect(typeof article.author_role).toBe('string');
54- // expect(typeof article.author_image_url).toBe('string');
55- // expect(typeof article.category_name).toBe('string');
56- // expect(typeof article.category_slug).toBe('string');
57- // expect(typeof article.relatedArticles ).toBe('array');
58- // });
45+ test ( 'getArticle should return an article with content' , async ( ) => {
46+ expect . assertions ( 14 ) ;
47+ const article = await getArticle ( 1 ) ;
48+ expect ( typeof article . id ) . toBe ( 'number' ) ;
49+ expect ( typeof article . title ) . toBe ( 'string' ) ;
50+ expect ( typeof article . subtitle ) . toBe ( 'string' ) ;
51+ expect ( typeof article . slug ) . toBe ( 'string' ) ;
52+ expect ( article . posted_on ) . toBeInstanceOf ( Date ) ;
53+ expect ( typeof article . article_image_url ) . toBe ( 'string' ) ;
54+ expect ( typeof article . summary ) . toBe ( 'string' ) ;
55+ expect ( typeof article . html_content ) . toBe ( 'string' ) ;
56+ expect ( typeof article . author_name ) . toBe ( 'string' ) ;
57+ expect ( typeof article . author_role ) . toBe ( 'string' ) ;
58+ expect ( typeof article . author_image_url ) . toBe ( 'string' ) ;
59+ expect ( typeof article . category_name ) . toBe ( 'string' ) ;
60+ expect ( typeof article . category_slug ) . toBe ( 'string' ) ;
61+ expect ( typeof article . related_articles ) . toBe ( 'array' ) ;
62+ } ) ;
5963
6064 // test('calculateReadingTime should calculate reading time', async () => {
6165 // });
6266
6367 // test('getArticle should list reading time', async () => {
6468 // });
6569
66- // test('getRelatedArticles should return a summary array', async () => {
67- // expect.assertions(13);
68- // const relatedArticles = await getRelatedArticles(1);
69- // const article = relatedArticles[0];
70- // expect(typeof relatedArticles).toBe('ar ray ');
71- // expect(typeof article.id).toBe('number');
72- // expect(typeof article.title).toBe('string');
73- // expect(typeof article.subtitle).toBe('string');
74- // expect(typeof article.slug).toBe('string');
75- // expect(typeof article.posted_on).toBe('string');
76- // expect(typeof article.article_image_url).toBe('string');
77- // expect(typeof article.summary).toBe('string');
78- // expect(typeof article.author_name).toBe('string');
79- // expect(typeof article.author_role).toBe('string');
80- // expect(typeof article.author_image_url).toBe('string');
81- // expect(typeof article.category_name).toBe('string');
82- // expect(typeof article.category_slug).toBe('string');
83- // });
70+ test ( 'getRelatedArticles should return a summary array' , async ( ) => {
71+ expect . assertions ( 13 ) ;
72+ const relatedArticles = await getRelatedArticles ( 1 ) ;
73+ const article = relatedArticles [ 0 ] ;
74+ expect ( typeof relatedArticles ) . toBe ( 'array ' ) ;
75+ expect ( typeof article . id ) . toBe ( 'number' ) ;
76+ expect ( typeof article . title ) . toBe ( 'string' ) ;
77+ expect ( typeof article . subtitle ) . toBe ( 'string' ) ;
78+ expect ( typeof article . slug ) . toBe ( 'string' ) ;
79+ expect ( typeof article . posted_on ) . toBe ( 'string' ) ;
80+ expect ( typeof article . article_image_url ) . toBe ( 'string' ) ;
81+ expect ( typeof article . summary ) . toBe ( 'string' ) ;
82+ expect ( typeof article . author_name ) . toBe ( 'string' ) ;
83+ expect ( typeof article . author_role ) . toBe ( 'string' ) ;
84+ expect ( typeof article . author_image_url ) . toBe ( 'string' ) ;
85+ expect ( typeof article . category_name ) . toBe ( 'string' ) ;
86+ expect ( typeof article . category_slug ) . toBe ( 'string' ) ;
87+ } ) ;
8488
8589 // test('addArticle should add an article correctly', async () => {
8690 // });
0 commit comments