Skip to content

Commit e18396c

Browse files
authored
avoid mocking in robots.txt testing (github#26018)
* avoid mocking in robots.txt testing * remove package
1 parent e6c4b73 commit e18396c

File tree

3 files changed

+6
-288
lines changed

3 files changed

+6
-288
lines changed

package-lock.json

Lines changed: 0 additions & 274 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
"make-promises-safe": "^5.1.0",
150150
"minimatch": "^5.0.0",
151151
"mkdirp": "^1.0.4",
152-
"mock-express-response": "^0.3.0",
153152
"mockdate": "^3.0.5",
154153
"nock": "^13.2.2",
155154
"nodemon": "^2.0.15",

tests/rendering/robots-txt.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import languages from '../../lib/languages.js'
22
import robotsParser from 'robots-parser'
3-
import robotsMiddleware from '../../middleware/robots.js'
43
import { get } from '../helpers/supertest.js'
5-
import MockExpressResponse from 'mock-express-response'
64
import { jest } from '@jest/globals'
75

86
describe('robots.txt', () => {
@@ -36,17 +34,12 @@ describe('robots.txt', () => {
3634
})
3735

3836
it('disallows indexing of azurecontainer.io domains', async () => {
39-
const req = {
40-
hostname: 'docs-internal-preview-12345-asdfz.azurecontainer.io',
41-
path: '/robots.txt',
42-
}
43-
const res = new MockExpressResponse()
44-
const next = () => {
45-
/* no op */
46-
}
47-
48-
await robotsMiddleware(req, res, next)
49-
expect(res._getString()).toEqual('User-agent: *\nDisallow: /')
37+
const res = await get('/robots.txt', {
38+
headers: {
39+
host: 'docs-internal-preview-12345-asdfz.azurecontainer.io',
40+
},
41+
})
42+
expect(res.text).toEqual('User-agent: *\nDisallow: /')
5043
})
5144

5245
it('does not have duplicate lines', () => {

0 commit comments

Comments
 (0)