Skip to content

Commit 92a6258

Browse files
authored
Adds tests for plugin event switching based on environment variable (#563)
1 parent 56f231f commit 92a6258

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/index.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import lighthousePlugin from './index.js';
2+
3+
describe('lighthousePlugin plugin events', () => {
4+
describe('onPostBuild', () => {
5+
it('should return only the expected event function', async () => {
6+
const events = lighthousePlugin();
7+
expect(events).toEqual({
8+
onPostBuild: expect.any(Function),
9+
});
10+
});
11+
});
12+
13+
describe('onSuccess', () => {
14+
beforeEach(() => {
15+
process.env.RUN_ON_SUCCESS = 'true';
16+
});
17+
afterEach(() => {
18+
delete process.env.RUN_ON_SUCCESS;
19+
});
20+
it('should return only the expected event function', async () => {
21+
const events = lighthousePlugin();
22+
expect(events).toEqual({
23+
onSuccess: expect.any(Function),
24+
});
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)