Skip to content

Commit

Permalink
chore(network): avoid using if/else inside test case (#8095)
Browse files Browse the repository at this point in the history
  • Loading branch information
marabesi committed Mar 4, 2022
1 parent 3b8b9ad commit 9ca57f1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/network.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
setupTestPageAndContextHooks,
itFailsFirefox,
describeFailsFirefox,
itChromeOnly,
itFirefoxOnly,
} from './mocha-utils'; // eslint-disable-line import/extensions
import { HTTPResponse } from '../lib/cjs/puppeteer/api-docs-entry.js';

Expand Down Expand Up @@ -113,14 +115,17 @@ describe('network', function () {
});

describe('Request.headers', function () {
it('should work', async () => {
const { page, server, isChrome } = getTestState();
itChromeOnly('should define Chrome as user agent header', async () => {
const { page, server } = getTestState();
const response = await page.goto(server.EMPTY_PAGE);
expect(response.request().headers()['user-agent']).toContain('Chrome');
});

itFirefoxOnly('should define Firefox as user agent header', async () => {
const { page, server } = getTestState();

const response = await page.goto(server.EMPTY_PAGE);
if (isChrome)
expect(response.request().headers()['user-agent']).toContain('Chrome');
else
expect(response.request().headers()['user-agent']).toContain('Firefox');
expect(response.request().headers()['user-agent']).toContain('Firefox');
});
});

Expand Down

0 comments on commit 9ca57f1

Please sign in to comment.