playwright/tests/playwright-test/codegen.spec.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-10-25 16:18:01 +02:00
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { test, expect } from './playwright-test-fixtures';
import { generatePlaywrightRequestCall } from '../../packages/playwright-core/src/utils/isomorphic/codegen';
test('generatePlaywrightRequestCall', () => {
expect(generatePlaywrightRequestCall({
url: 'http://example.com/foo?bar=baz',
method: 'GET',
headers: [{ name: 'User-Agent', value: 'Mozilla/5.0' }],
httpVersion: '1.1',
cookies: [],
queryString: [],
headersSize: 0,
bodySize: 0,
comment: '',
}, 'foo')).toEqual(`
await page.request.GET("http://example.com/foo", {
headers: {
"User-Agent": "Mozilla/5.0"
},
);`.trim());
});