Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(utils): increase coverage (#2156)
- Loading branch information
1 parent
9c171d1
commit 1f9f9dc
Showing
12 changed files
with
273 additions
and
9 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,35 @@ | ||
'use strict'; | ||
|
||
const runBonjour = require('../../../lib/utils/runBonjour'); | ||
|
||
describe('runBonjour', () => { | ||
let mock; | ||
let publish = jest.fn(); | ||
let unpublishAll = jest.fn(); | ||
|
||
beforeAll(() => { | ||
mock = jest.mock('bonjour', () => () => { | ||
return { | ||
publish, | ||
unpublishAll, | ||
}; | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
publish = jest.fn(); | ||
unpublishAll = jest.fn(); | ||
}); | ||
|
||
afterAll(() => { | ||
mock.mockRestore(); | ||
}); | ||
|
||
it('should call bonjour.publish', () => { | ||
runBonjour({ | ||
port: 1111, | ||
}); | ||
|
||
expect(publish.mock.calls[0][0]).toMatchSnapshot(); | ||
}); | ||
}); |
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,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`runBonjour should call bonjour.publish 1`] = ` | ||
Object { | ||
"name": "Webpack Dev Server", | ||
"port": 1111, | ||
"subtypes": Array [ | ||
"webpack", | ||
], | ||
"type": "http", | ||
} | ||
`; |
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`colors error should disable color 1`] = `"test"`; | ||
|
||
exports[`colors error should enable color 1`] = `"[1m[31mtest[39m[22m"`; | ||
|
||
exports[`colors info should disable color 1`] = `"test"`; | ||
|
||
exports[`colors info should enable color 1`] = `"[1m[34mtest[39m[22m"`; |
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
'use strict'; | ||
|
||
const colors = require('../../../lib/utils/colors'); | ||
|
||
describe('colors', () => { | ||
describe('info', () => { | ||
it('should disable color', () => { | ||
expect(colors.info(false, 'test')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should enable color', () => { | ||
expect(colors.info(true, 'test')).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('error', () => { | ||
it('should disable color', () => { | ||
expect(colors.error(false, 'test')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should enable color', () => { | ||
expect(colors.error(true, 'test')).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
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,16 @@ | ||
'use strict'; | ||
|
||
const createCertificate = require('../../../lib/utils/createCertificate'); | ||
|
||
describe('createCertificate', () => { | ||
it('should have keys', () => { | ||
expect(createCertificate([{ name: 'commonName', value: 'wds' }])).toEqual( | ||
expect.objectContaining({ | ||
private: expect.any(String), | ||
public: expect.any(String), | ||
cert: expect.any(String), | ||
fingerprint: expect.any(String), | ||
}) | ||
); | ||
}); | ||
}); |
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
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