Skip to content

Commit

Permalink
Split giant cookie.ts into multiple files.
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhsf committed Aug 23, 2023
1 parent d64717f commit 128a0a4
Show file tree
Hide file tree
Showing 37 changed files with 2,505 additions and 2,485 deletions.
2 changes: 1 addition & 1 deletion lib/__tests__/canonicalDomain.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { canonicalDomain } from '../cookie'
import { canonicalDomain } from '../cookie/canonicalDomain'

// port of tests/domain_and_path_test.js (canonicalDomain tests for domain normalization)
describe('canonicalDomain', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/cookie.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import { Cookie } from '../cookie'
import { Cookie } from '../cookie/cookie'

jest.useFakeTimers()

Expand Down
14 changes: 6 additions & 8 deletions lib/__tests__/cookieJar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import {
Cookie,
CookieJar,
MemoryCookieStore,
ParameterError,
SerializedCookieJar,
Store,
} from '../cookie'
import { Cookie } from '../cookie/cookie'
import { CookieJar } from '../cookie/cookieJar'
import type { SerializedCookieJar } from '../cookie/constants'
import { MemoryCookieStore } from '../memstore'
import { Store } from '../store'
import { ParameterError } from '../validators'

jest.useFakeTimers()

Expand Down
3 changes: 2 additions & 1 deletion lib/__tests__/cookiePrefixes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CookieJar, PrefixSecurityEnum } from '../cookie'
import { PrefixSecurityEnum } from '../cookie/constants'
import { CookieJar } from '../cookie/cookieJar'

let cookieJar: CookieJar
const insecureUrl = 'http://www.example.com'
Expand Down
4 changes: 3 additions & 1 deletion lib/__tests__/cookieSorting.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Cookie, cookieCompare, CookieJar } from '../cookie'
import { Cookie } from '../cookie/cookie'
import { cookieCompare } from '../cookie/cookieCompare'
import { CookieJar } from '../cookie/cookieJar'

jest.useFakeTimers()

Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/cookieToAndFromJson.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cookie } from '../cookie'
import { Cookie } from '../cookie/cookie'

jest.useFakeTimers()

Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/cookieToString.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cookie } from '../cookie'
import { Cookie } from '../cookie/cookie'

describe('Cookie.toString()', () => {
const parse = (cookieString: string): Cookie => {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type EquivalenceDateParsingTestCase = {
[key: string]: string
}

import { parseDate } from '../cookie'
import { parseDate } from '../cookie/parseDate'

const dateTests: DateParsingTestCase = {
'Wed, 09 Jun 2021 10:18:14 GMT': true,
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/defaultPath.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defaultPath } from '../cookie'
import { defaultPath } from '../cookie/defaultPath'

// port of tests/domain_and_path_test.js (default path tests)
describe('defaultPath', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/domainMatch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { domainMatch } from '../cookie'
import { domainMatch } from '../cookie/domainMatch'

// port of tests/domain_and_path_test.js (domain match tests)
describe('domainMatch', () => {
Expand Down
3 changes: 2 additions & 1 deletion lib/__tests__/ietf.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import { CookieJar, parseDate } from '../cookie'
import url from 'url'
import parserData from './data/parser'
import bsdExampleDates from './data/dates/bsd-examples'
import exampleDates from './data/dates/examples'
import { CookieJar } from '../cookie/cookieJar'
import { parseDate } from '../cookie/parseDate'

describe('IETF http state tests', () => {
describe('Set/get cookie tests', () => {
Expand Down
16 changes: 6 additions & 10 deletions lib/__tests__/jarSerialization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

import {
Cookie,
CookieJar,
MemoryCookieStore,
SerializedCookie,
SerializedCookieJar,
Store,
version,
} from '../cookie'
import { Cookie } from '../cookie/cookie'
import { CookieJar } from '../cookie/cookieJar'
import type { SerializedCookie, SerializedCookieJar } from '../cookie/constants'
import { MemoryCookieStore } from '../memstore'
import { Store } from '../store'
import { version } from '../version'

jest.useFakeTimers()

Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/lifetime.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cookie } from '../cookie'
import { Cookie } from '../cookie/cookie'

jest.useFakeTimers()

Expand Down
3 changes: 2 additions & 1 deletion lib/__tests__/memoryCookieStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cookie, MemoryCookieStore } from '../cookie'
import { Cookie } from '../cookie/cookie'
import { MemoryCookieStore } from '../memstore'

describe('MemoryCookieStore', () => {
it('should have no static methods', () => {
Expand Down
7 changes: 4 additions & 3 deletions lib/__tests__/nodeUtilFallback.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getCustomInspectSymbol, getUtilInspect } from '../utilHelper'
import util from 'util'
import { Cookie, CookieJar, MemoryCookieStore } from '../cookie'
import { inspectFallback } from '../memstore'
import { Cookie } from '../cookie/cookie'
import { CookieJar } from '../cookie/cookieJar'
import { MemoryCookieStore, inspectFallback } from '../memstore'
import { getCustomInspectSymbol, getUtilInspect } from '../utilHelper'

jest.useFakeTimers()

Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cookie } from '../cookie'
import { Cookie } from '../cookie/cookie'
import { performance } from 'node:perf_hooks'

describe('Cookie.parse', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/pathMatch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pathMatch } from '../cookie'
import { pathMatch } from '../pathMatch'

// port of tests/domain_and_path_test.js (path match tests)
describe('pathMatch', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/permuteDomain.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { permuteDomain } from '../cookie'
import { permuteDomain } from '../permuteDomain'

// port of tests/domain_and_path_test.js (permute domain tests)
describe('permuteDomain', () => {
Expand Down
3 changes: 2 additions & 1 deletion lib/__tests__/permutePath.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { pathMatch, permutePath } from '../cookie'
import { permutePath } from '../cookie/permutePath'
import { pathMatch } from '../pathMatch'

// port of tests/domain_and_path_test.js (permute path tests)
describe('permutePath', () => {
Expand Down
3 changes: 2 additions & 1 deletion lib/__tests__/regression.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cookie, CookieJar } from '../cookie'
import type { Cookie } from '../cookie/cookie'
import { CookieJar } from '../cookie/cookieJar'

const url = 'http://www.example.com'

Expand Down
24 changes: 7 additions & 17 deletions lib/__tests__/removeAll.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import {
Callback,
Cookie,
CookieJar,
MemoryCookieStore,
Store,
} from '../cookie'
import spyOn = jest.spyOn
import SpyInstance = jest.SpyInstance
import type { Cookie } from '../cookie/cookie'
import { CookieJar } from '../cookie/cookieJar'
import { MemoryCookieStore } from '../memstore'
import { Store } from '../store'
import type { Callback } from '../utils'

const url = 'http://example.com/index.html'

Expand Down Expand Up @@ -36,10 +32,7 @@ describe('store removeAllCookies API', () => {

// replace remove cookie behavior to throw an error on the 4th invocation
const _removeCookie = store.removeCookie.bind(store)
const spy: SpyInstance<ReturnType<typeof _removeCookie>> = spyOn(
store,
'removeCookie',
)
const spy = jest.spyOn(store, 'removeCookie')
spy.mockImplementationOnce(
(domain: string, path: string, key: string, callback: Callback<void>) =>
_removeCookie.call(store, domain, path, key, callback),
Expand Down Expand Up @@ -79,10 +72,7 @@ describe('store removeAllCookies API', () => {

// replace remove cookie behavior to throw an error on the 4th invocation
const _removeCookie = store.removeCookie.bind(store)
const spy: SpyInstance<ReturnType<typeof _removeCookie>> = spyOn(
store,
'removeCookie',
)
const spy = jest.spyOn(store, 'removeCookie')
spy.mockImplementation(
(
domain: string,
Expand Down
3 changes: 2 additions & 1 deletion lib/__tests__/sameSite.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cookie, CookieJar } from '../cookie'
import { Cookie } from '../cookie/cookie'
import { CookieJar } from '../cookie/cookieJar'

const url = 'http://example.com/index.html'

Expand Down
Loading

0 comments on commit 128a0a4

Please sign in to comment.