-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sitemap): create test and get routes
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// FIX: tests are slow - use unit tests instead of integration tests | ||
// TODO: capture console log from run function | ||
const fs = require("fs"); | ||
const writeFileSpy = jest.spyOn(fs, "writeFile"); | ||
writeFileSpy.mockImplementation((file, data, cb) => cb()); | ||
|
||
const { mockFs } = require("./helper.js"); | ||
const { run } = require("./../index.js"); | ||
const snapRun = (fs, options) => | ||
run( | ||
{ | ||
// for Travis CI | ||
puppeteerArgs: ["--no-sandbox", "--disable-setuid-sandbox"], | ||
// sometimes web server from previous test have not enough time to shut down | ||
// as a result you get `Error: listen EADDRINUSE :::45678` | ||
// to prevent this we use random port | ||
port: Math.floor(Math.random() * 1000 + 45000), | ||
...options | ||
}, | ||
{ | ||
fs | ||
} | ||
); | ||
|
||
describe("generateSitemap", () => { | ||
console.log('\n--describing generate sitemap test--\n') | ||
const source = "tests/examples/many-pages"; | ||
const include = ["/index.html"]; | ||
const { fs, filesCreated, content } = mockFs(); | ||
beforeAll(() => snapRun(fs, { source, include })); | ||
test("removes blob resources from final html but sitemap", () => { | ||
console.log('--fs') | ||
console.log(fs) | ||
console.log('--content(0)') | ||
console.log(content(0)) | ||
expect(content(0)).not.toMatch('<link rel="stylesheet" href="blob:'); | ||
}); | ||
}); | ||
|
||
describe.skip("publicPath", () => {}); | ||
|
||
describe.skip("skipThirdPartyRequests", () => {}); | ||
|
||
describe.skip("waitFor", () => {}); | ||
|
||
describe.skip("externalServer", () => {}); |