Skip to content

Commit

Permalink
test: more
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jun 3, 2021
1 parent 6433303 commit d8e24ad
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions test/server/historyApiFallback-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d8e24ad

Please sign in to comment.