-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Buffer is now a subtype of Uint8Array, so no special handling is required anymore
- Loading branch information
Showing
12 changed files
with
44 additions
and
44 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import { expect } from 'chai'; | ||
import { toStream, readToEnd } from '../lib/index.js'; | ||
import { toStream, readToEnd } from '@openpgp/web-stream-tools'; | ||
|
||
describe('Browser integration tests', () => { | ||
it('toStream/readToEnd', async () => { | ||
it('accepts readable stream', async () => { | ||
const input = 'chunk'; | ||
const streamedData = toStream('chunk'); | ||
const stream = new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(input); | ||
controller.close(); | ||
} | ||
}); | ||
const streamedData = toStream(stream); | ||
expect(await readToEnd(streamedData)).to.equal(input); | ||
}) | ||
}); | ||
}) |
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,17 @@ | ||
import { expect } from 'chai'; | ||
import { toStream, readToEnd, slice } from '@openpgp/web-stream-tools'; | ||
|
||
describe('Common integration tests', () => { | ||
it('toStream/readToEnd', async () => { | ||
const input = 'chunk'; | ||
const streamedData = toStream('chunk'); | ||
expect(await readToEnd(streamedData)).to.equal(input); | ||
}); | ||
|
||
it('slice', async () => { | ||
const input = 'another chunk'; | ||
const streamedData = toStream(input); | ||
const slicedStream = slice(streamedData, 8); | ||
expect(await readToEnd(slicedStream)).to.equal('chunk'); | ||
}) | ||
}) |
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,29 +1,23 @@ | ||
import { expect } from 'chai'; | ||
import { Readable } from 'stream'; | ||
import { Readable as NodeNativeReadableStream } from 'stream'; | ||
import { ReadableStream as NodeWebReadableStream } from 'stream/web'; | ||
import { toStream, readToEnd } from '@openpgp/web-stream-tools'; | ||
|
||
describe('Node integration tests', () => { | ||
it('throws on node native stream', async () => { | ||
const input = new Readable(); | ||
const input = new NodeNativeReadableStream(); | ||
expect(() => toStream(input)).to.throw(/Native Node streams are no longer supported/); | ||
}); | ||
|
||
it('accepts on node web stream', async () => { | ||
it('accepts node web stream', async () => { | ||
const input = 'chunk'; | ||
const stream = new NodeWebReadableStream({ | ||
start(controller) { | ||
controller.enqueue('chunk'); | ||
controller.enqueue(input); | ||
controller.close(); | ||
} | ||
}); | ||
const streamedData = toStream(stream); | ||
expect(await readToEnd(streamedData)).to.equal(input); | ||
}); | ||
|
||
it('toStream/readToEnd', async () => { | ||
const input = 'chunk'; | ||
const streamedData = toStream('chunk'); | ||
expect(await readToEnd(streamedData)).to.equal(input); | ||
}) | ||
}) | ||
}); |