Skip to content
Snippets Groups Projects
Commit 492fc159 authored by Xiao Gui's avatar Xiao Gui
Browse files

feat: added testing for browser 404

parent fd9b9e0d
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cookie": "^0.4.0",
"cors": "^2.8.5",
"dotenv": "^6.2.0",
"google-spreadsheet": "^3.0.8",
......
const sinon = require('sinon')
const cookie = require('cookie')
const { Store, NotFoundError } = require('./store')
const userStore = require('../user/store')
......@@ -102,6 +103,32 @@ describe('> saneUrl/index.js', () => {
getStub.restore()
})
it('> get on expired with txt html header sets cookie and redirect', async () => {
const body = {
...payload,
expiry: Date.now() - 1e3 * 60
}
const getStub = sinon
.stub(Store.prototype, 'get')
.returns(Promise.resolve(JSON.stringify(body)))
const { statusCode, headers } = await got(`http://localhost:50000/${name}`, {
headers: {
'accept': 'text/html'
},
followRedirect: false
})
expect(statusCode).to.be.greaterThan(300)
expect(statusCode).to.be.lessThan(303)
expect(getStub.calledWith(name)).to.be.true
getStub.restore()
const c = cookie.parse(...headers['set-cookie'])
expect(!!c['iav-error']).to.be.true
})
describe('> set', () => {
it('> checks if the name is available', async () => {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment