From d8e24adeb6c871f791ac8db33c46b3a6a148b537 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 3 Jun 2021 14:55:56 +0300 Subject: [PATCH] test: more --- test/server/historyApiFallback-option.test.js | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/test/server/historyApiFallback-option.test.js b/test/server/historyApiFallback-option.test.js index 2e470d9822..edc5a7e221 100644 --- a/test/server/historyApiFallback-option.test.js +++ b/test/server/historyApiFallback-option.test.js @@ -178,6 +178,102 @@ describe('historyApiFallback option', () => { }); }); + describe('as object with the "verbose" option', () => { + let consoleSpy; + + beforeAll((done) => { + consoleSpy = jest.spyOn(global.console, 'log'); + + server = testServer.start( + config, + { + historyApiFallback: { + index: '/bar.html', + verbose: true, + }, + port, + }, + done + ); + req = request(server.app); + }); + + afterAll(() => { + consoleSpy.mockRestore(); + }); + + it('request to directory and log', (done) => { + req + .get('/foo') + .accept('html') + .expect(200, /Foobar/, (error) => { + if (error) { + done(error); + + return; + } + + expect(consoleSpy).toHaveBeenCalledWith( + 'Rewriting', + 'GET', + '/foo', + 'to', + '/bar.html' + ); + + done(); + }); + }); + }); + + describe('as object with the "logger" option', () => { + let consoleSpy; + + beforeAll((done) => { + consoleSpy = jest.spyOn(global.console, 'log'); + + server = testServer.start( + config, + { + historyApiFallback: { + index: '/bar.html', + logger: consoleSpy, + }, + port, + }, + done + ); + req = request(server.app); + }); + + afterAll(() => { + consoleSpy.mockRestore(); + }); + + it('request to directory and log', (done) => { + req + .get('/foo') + .accept('html') + .expect(200, /Foobar/, (error) => { + if (error) { + done(error); + + return; + } + + expect(consoleSpy).toHaveBeenCalledWith( + 'Rewriting', + 'GET', + '/foo', + 'to', + '/bar.html' + ); + + done(); + }); + }); + }); + describe('in-memory files', () => { beforeAll((done) => { server = testServer.start(