-
-
Notifications
You must be signed in to change notification settings - Fork 669
chore: use testcontext for test:cookies #4578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Uzlopak
wants to merge
1
commit into
main
Choose a base branch
from
test-cookies
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,85 +1,84 @@ | ||
'use strict' | ||
|
||
const { test, describe } = require('node:test') | ||
const { strictEqual } = require('node:assert') | ||
|
||
const { | ||
isCTLExcludingHtab | ||
} = require('../../lib/web/cookies/util') | ||
|
||
describe('isCTLExcludingHtab', () => { | ||
test('should return false for 0x00 - 0x08 characters', () => { | ||
strictEqual(isCTLExcludingHtab('\x00'), true) | ||
strictEqual(isCTLExcludingHtab('\x01'), true) | ||
strictEqual(isCTLExcludingHtab('\x02'), true) | ||
strictEqual(isCTLExcludingHtab('\x03'), true) | ||
strictEqual(isCTLExcludingHtab('\x04'), true) | ||
strictEqual(isCTLExcludingHtab('\x05'), true) | ||
strictEqual(isCTLExcludingHtab('\x06'), true) | ||
strictEqual(isCTLExcludingHtab('\x07'), true) | ||
strictEqual(isCTLExcludingHtab('\x08'), true) | ||
test('should return false for 0x00 - 0x08 characters', (t) => { | ||
t.assert.strictEqual(isCTLExcludingHtab('\x00'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x01'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x02'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x03'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x04'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x05'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x06'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x07'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x08'), true) | ||
}) | ||
|
||
test('should return false for 0x09 HTAB character', () => { | ||
strictEqual(isCTLExcludingHtab('\x09'), false) | ||
test('should return false for 0x09 HTAB character', (t) => { | ||
t.assert.strictEqual(isCTLExcludingHtab('\x09'), false) | ||
}) | ||
|
||
test('should return false for 0x0A - 0x1F characters', () => { | ||
strictEqual(isCTLExcludingHtab('\x0A'), true) | ||
strictEqual(isCTLExcludingHtab('\x0B'), true) | ||
strictEqual(isCTLExcludingHtab('\x0C'), true) | ||
strictEqual(isCTLExcludingHtab('\x0D'), true) | ||
strictEqual(isCTLExcludingHtab('\x0E'), true) | ||
strictEqual(isCTLExcludingHtab('\x0F'), true) | ||
strictEqual(isCTLExcludingHtab('\x10'), true) | ||
strictEqual(isCTLExcludingHtab('\x11'), true) | ||
strictEqual(isCTLExcludingHtab('\x12'), true) | ||
strictEqual(isCTLExcludingHtab('\x13'), true) | ||
strictEqual(isCTLExcludingHtab('\x14'), true) | ||
strictEqual(isCTLExcludingHtab('\x15'), true) | ||
strictEqual(isCTLExcludingHtab('\x16'), true) | ||
strictEqual(isCTLExcludingHtab('\x17'), true) | ||
strictEqual(isCTLExcludingHtab('\x18'), true) | ||
strictEqual(isCTLExcludingHtab('\x19'), true) | ||
strictEqual(isCTLExcludingHtab('\x1A'), true) | ||
strictEqual(isCTLExcludingHtab('\x1B'), true) | ||
strictEqual(isCTLExcludingHtab('\x1C'), true) | ||
strictEqual(isCTLExcludingHtab('\x1D'), true) | ||
strictEqual(isCTLExcludingHtab('\x1E'), true) | ||
strictEqual(isCTLExcludingHtab('\x1F'), true) | ||
test('should return false for 0x0A - 0x1F characters', (t) => { | ||
t.assert.strictEqual(isCTLExcludingHtab('\x0A'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x0B'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x0C'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x0D'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x0E'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x0F'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x10'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x11'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x12'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x13'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x14'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x15'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x16'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x17'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x18'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x19'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x1A'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x1B'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x1C'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x1D'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x1E'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x1F'), true) | ||
}) | ||
|
||
test('should return false for a 0x7F character', t => { | ||
strictEqual(isCTLExcludingHtab('\x7F'), true) | ||
t.assert.strictEqual(isCTLExcludingHtab('\x7F'), true) | ||
}) | ||
|
||
test('should return false for a 0x20 / space character', t => { | ||
strictEqual(isCTLExcludingHtab(' '), false) | ||
t.assert.strictEqual(isCTLExcludingHtab(' '), false) | ||
}) | ||
|
||
test('should return false for a printable character', t => { | ||
strictEqual(isCTLExcludingHtab('A'), false) | ||
strictEqual(isCTLExcludingHtab('Z'), false) | ||
strictEqual(isCTLExcludingHtab('a'), false) | ||
strictEqual(isCTLExcludingHtab('z'), false) | ||
strictEqual(isCTLExcludingHtab('!'), false) | ||
t.assert.strictEqual(isCTLExcludingHtab('A'), false) | ||
t.assert.strictEqual(isCTLExcludingHtab('Z'), false) | ||
t.assert.strictEqual(isCTLExcludingHtab('a'), false) | ||
t.assert.strictEqual(isCTLExcludingHtab('z'), false) | ||
t.assert.strictEqual(isCTLExcludingHtab('!'), false) | ||
}) | ||
|
||
test('should return false for an empty string', () => { | ||
strictEqual(isCTLExcludingHtab(''), false) | ||
test('should return false for an empty string', (t) => { | ||
t.assert.strictEqual(isCTLExcludingHtab(''), false) | ||
}) | ||
|
||
test('all printable characters (0x20 - 0x7E)', () => { | ||
test('all printable characters (0x20 - 0x7E)', (t) => { | ||
for (let i = 0x20; i < 0x7F; i++) { | ||
strictEqual(isCTLExcludingHtab(String.fromCharCode(i)), false) | ||
t.assert.strictEqual(isCTLExcludingHtab(String.fromCharCode(i)), false) | ||
} | ||
}) | ||
|
||
test('valid case', () => { | ||
strictEqual(isCTLExcludingHtab('Space=Cat; Secure; HttpOnly; Max-Age=2'), false) | ||
test('valid case', (t) => { | ||
t.assert.strictEqual(isCTLExcludingHtab('Space=Cat; Secure; HttpOnly; Max-Age=2'), false) | ||
}) | ||
|
||
test('invalid case', () => { | ||
strictEqual(isCTLExcludingHtab('Space=Cat; Secure; HttpOnly; Max-Age=2\x7F'), true) | ||
test('invalid case', (t) => { | ||
t.assert.strictEqual(isCTLExcludingHtab('Space=Cat; Secure; HttpOnly; Max-Age=2\x7F'), true) | ||
}) | ||
}) |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
'use strict' | ||
|
||
const { test, describe } = require('node:test') | ||
const { strictEqual } = require('node:assert') | ||
|
||
const { | ||
toIMFDate | ||
} = require('../../lib/web/cookies/util') | ||
|
||
describe('toIMFDate', () => { | ||
test('should return the same as Date.prototype.toGMTString()', () => { | ||
test('should return the same as Date.prototype.toGMTString()', (t) => { | ||
for (let i = 1; i <= 1e6; i *= 2) { | ||
const date = new Date(i) | ||
strictEqual(toIMFDate(date), date.toGMTString()) | ||
t.assert.strictEqual(toIMFDate(date), date.toGMTString()) | ||
} | ||
for (let i = 0; i <= 1e6; i++) { | ||
const date = new Date(Math.trunc(Math.random() * 8640000000000000)) | ||
strictEqual(toIMFDate(date), date.toGMTString()) | ||
t.assert.strictEqual(toIMFDate(date), date.toGMTString()) | ||
} | ||
}) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This should be wrapped in a separate
describe
block or usetest
instead of being nested directly within the existing describe block. The original structure had this as a separate describe block.Copilot uses AI. Check for mistakes.