-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,530 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const request = require('supertest') | ||
const express = require('express') | ||
const newsRouter = require( "../../routes/views/news") | ||
const fs = require('fs') | ||
|
||
const app = new express(); | ||
app.set('views', 'templates/views'); | ||
app.set('view engine', 'pug'); | ||
app.use("/news", newsRouter) | ||
|
||
describe('News Routes', function () { | ||
const testFile = fs.readFileSync('tests/integration/testData/news.json',{encoding:'utf8', flag:'r'}) | ||
|
||
test('responds to /', async () => { | ||
jest.mock('fs') | ||
jest.spyOn(fs, 'readFileSync').mockReturnValueOnce(testFile) | ||
|
||
|
||
const res = await request(app).get('/news'); | ||
expect(res.header['content-type']).toBe('text/html; charset=utf-8'); | ||
expect(res.statusCode).toBe(200); | ||
expect(res.text).toContain('Welcome to the patchnotes for the 3750 patch.'); | ||
expect(res.text).toContain('New FAF Website'); | ||
expect(res.text).toContain('Game version 3738'); | ||
expect(res.text).toContain('Weapon Target Checking Intervals'); | ||
}); | ||
|
||
test('responds to /:slug', async () => { | ||
jest.mock('fs') | ||
jest.spyOn(fs, 'readFileSync').mockReturnValueOnce(testFile) | ||
|
||
|
||
const res = await request(app).get('/news/balance-patch-3750-is-live'); | ||
expect(res.header['content-type']).toBe('text/html; charset=utf-8'); | ||
expect(res.statusCode).toBe(200); | ||
expect(res.text).toContain('Welcome to the patchnotes for the 3750 patch.'); | ||
}); | ||
|
||
test('responds to /:slug with redirect if called with old slug', async () => { | ||
jest.mock('fs') | ||
jest.spyOn(fs, 'readFileSync').mockReturnValueOnce(testFile) | ||
|
||
|
||
const res = await request(app).get('/news/Balance-Patch-3750-Is-Live'); | ||
expect(res.statusCode).toBe(301); | ||
expect(res.header['location']).toBe('balance-patch-3750-is-live'); | ||
}); | ||
}); |
Oops, something went wrong.