-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2112 from cjihrig/mv-test-dir
src: move test directory under `src/`
- Loading branch information
Showing
15 changed files
with
101 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { EventEmitter } from 'node:events'; | ||
|
||
export class CallAwaiter extends EventEmitter { | ||
public awaitCall(event: string) { | ||
return new Promise<any[]>((resolve) => { | ||
this.once(event, resolve); | ||
}); | ||
} | ||
|
||
public resolveCall(event: string) { | ||
return (...args: any[]) => this.emit(event, ...args); | ||
} | ||
} |
This file contains 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,4 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
// Just echo back all the args | ||
console.log(process.argv.slice(2).join(' ')) | ||
console.log(process.argv.slice(2).join(' ')); |
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { expect } from 'chai'; | ||
import { RequestOptions, Agent } from 'node:https'; | ||
import { Matcher } from 'ts-mockito/lib/matcher/type/Matcher'; | ||
|
||
export function matchBuffer(channel: number, contents: string): StringBufferMatcher { | ||
return new StringBufferMatcher(channel, contents); | ||
} | ||
|
||
class StringBufferMatcher extends Matcher { | ||
constructor( | ||
private channel: number, | ||
private contents: string, | ||
) { | ||
super(); | ||
} | ||
|
||
public valueOf(): string { | ||
return this.contents; | ||
} | ||
|
||
public match(value: any): boolean { | ||
if (value instanceof Buffer) { | ||
const buffer = value as Buffer; | ||
const channel: number = buffer.readInt8(0); | ||
const contents: string = buffer.toString('utf8', 1); | ||
return this.channel === channel && this.contents === contents; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public toString(): string { | ||
return `buffer did not contain "${this.contents}"`; | ||
} | ||
} | ||
|
||
export function assertRequestAgentsEqual(agent1: Agent, agent2: Agent): void { | ||
const BUFFER_EQUAL_TRUE = 0; | ||
const ca1 = agent1.options.ca; | ||
const ca2 = agent2.options.ca; | ||
//@ts-ignore | ||
if (ca1 !== ca2 && Buffer.compare(ca1, ca2) !== BUFFER_EQUAL_TRUE) { | ||
throw 'unequal agent ca buffer'; | ||
} | ||
const cert1 = agent1.options.cert; | ||
const cert2 = agent2.options.cert; | ||
//@ts-ignore | ||
if (cert1 !== cert2 && Buffer.compare(cert1, cert2) !== BUFFER_EQUAL_TRUE) { | ||
throw 'unequal agent cert buffer'; | ||
} | ||
|
||
const key1 = agent1.options.key; | ||
const key2 = agent2.options.key; | ||
//@ts-ignore | ||
if (key1 !== key2 && Buffer.compare(key1, key2) !== BUFFER_EQUAL_TRUE) { | ||
throw 'unequal agent key buffer'; | ||
} | ||
|
||
expect(agent1.options.passphrase).to.equal(agent2.options.passphrase); | ||
expect(agent1.options.pfx).to.equal(agent2.options.pfx); | ||
expect(agent1.options.rejectUnauthorized).to.equal(agent2.options.rejectUnauthorized); | ||
} | ||
|
||
export function assertRequestOptionsEqual(options1: RequestOptions, options2: RequestOptions): void { | ||
//@ts-ignore agent has type Agent | Boolean which we expect to be populated with Agent here | ||
const agent1: Agent = options1.agent; | ||
//@ts-ignore | ||
const agent2: Agent = options2.agent; | ||
assertRequestAgentsEqual(agent1, agent2); | ||
|
||
expect(options1.auth).to.equal(options2.auth); | ||
expect(options1.headers).to.deep.equal(options2.headers); | ||
expect(options1.rejectUnauthorized).to.equal(options2.rejectUnauthorized); | ||
expect(options1.servername).to.equal(options2.servername); | ||
} |
4 changes: 2 additions & 2 deletions
4
test/resizable-writeable-stream-buffer.ts → ...test/resizable-writeable-stream-buffer.ts
This file contains 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,6 +1,6 @@ | ||
import { WritableStreamBuffer } from 'stream-buffers'; | ||
|
||
export class ResizableWriteableStreamBuffer extends WritableStreamBuffer implements NodeJS.WritableStream { | ||
public columns: number = 0; | ||
public rows: number = 0; | ||
public columns: number = 0; | ||
public rows: number = 0; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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