Created
          December 17, 2020 13:35 
        
      - 
      
 - 
        
Save HasanGokce/a1aaf6aa1cf1a91466ed7cff9b7d612a to your computer and use it in GitHub Desktop.  
    Response Content
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const {assert} = require('chai'); | |
| const request = require('supertest'); | |
| const {jsdom} = require('jsdom'); | |
| const app = require('../../app'); | |
| const parseTextFromHTML = (htmlAsString, selector) => { | |
| const selectedElement = jsdom(htmlAsString).querySelector(selector); | |
| if (selectedElement !== null) { | |
| return selectedElement.textContent; | |
| } else { | |
| throw new Error(`No element with selector ${selector} found in HTML string`); | |
| } | |
| }; | |
| describe('root page', () => { | |
| describe('GET request', () => { | |
| it('returns a 200 status', async () => { | |
| const response = await request(app). | |
| get('/'); | |
| assert.equal(response.status, 200); | |
| }); | |
| it('contains the correct title', async () => { | |
| const response = await request(app). | |
| get('/'); | |
| assert.equal(parseTextFromHTML(response.text, '#page-title'), 'Messaging App') | |
| }); | |
| }); | |
| }); | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment