Skip to content

Commit

Permalink
test(open-option): fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jun 10, 2019
1 parent c89d3c1 commit abeaa9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/utils/runOpen.js
Expand Up @@ -4,13 +4,11 @@ const open = require('opn');

function runOpen(uri, options, log) {
// https://github.com/webpack/webpack-dev-server/issues/1990
const openOptions = { wait: false };
let openOptions = { wait: false };
let openMessage = 'Unable to open browser';

if (typeof options.open === 'string') {
Object.assign(openOptions, {
app: options.open,
});
openOptions = Object.assign({}, openOptions, { app: options.open });
openMessage += `: ${options.open}`;
}

Expand Down
15 changes: 12 additions & 3 deletions test/server/open-option.test.js
Expand Up @@ -21,9 +21,18 @@ describe('open option', () => {
});

compiler.hooks.done.tap('webpack-dev-server', () => {
expect(opn.mock.calls[0]).toEqual(['http://localhost:8080/', {}]);
expect(opn.mock.invocationCallOrder[0]).toEqual(1);
server.close(done);
server.close(() => {
expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"http://localhost:8080/",
Object {
"wait": false,
},
]
`);
expect(opn.mock.invocationCallOrder[0]).toEqual(1);
done();
});
});

compiler.run(() => {});
Expand Down

0 comments on commit abeaa9c

Please sign in to comment.