Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests for UDP and crypto
  • Loading branch information
jure committed Dec 14, 2017
commit 5eb65070ca889d0e14d8d6aeced704745d14aa82
77 changes: 77 additions & 0 deletions test/parallel/test-accessor-properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'use strict';

require('../common');

// This tests that the accessor properties do not raise assersions
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: assertions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done.

// when called with incompatible receivers.

const assert = require('assert');

// Examples are things that calls StreamBase::AddMethods when setting up
// their prototype
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're here: can you punctuate the comments in this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) This comment barely made sense (it was early morning when the last commit came in), hopefully it’s better now.

const TTY = process.binding('tty_wrap').TTY;
const UDP = process.binding('udp_wrap').UDP;

// Or the accessor properties in crypto
const crypto = process.binding('crypto');

{
// Should throw instead of raise assertions
assert.throws(() => {
TTY.prototype.bytesRead;
}, TypeError);

assert.throws(() => {
TTY.prototype.fd;
}, TypeError);

assert.throws(() => {
TTY.prototype._externalStream;
}, TypeError);

assert.throws(() => {
UDP.prototype.fd;
}, TypeError);

assert.throws(() => {
crypto.SecureContext.prototype._external;
}, TypeError);

assert.throws(() => {
crypto.Connection.prototype._external;
}, TypeError);


// Should not throw for Object.getOwnPropertyDescriptor
assert.strictEqual(
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'),
'object'
);

assert.strictEqual(
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'fd'),
'object'
);

assert.strictEqual(
typeof Object.getOwnPropertyDescriptor(TTY.prototype, '_externalStream'),
'object'
);

assert.strictEqual(
typeof Object.getOwnPropertyDescriptor(UDP.prototype, 'fd'),
'object'
);

assert.strictEqual(
typeof Object.getOwnPropertyDescriptor(
crypto.SecureContext.prototype, '_external'),
'object'
);

assert.strictEqual(
typeof Object.getOwnPropertyDescriptor(
crypto.Connection.prototype, '_external'),
'object'
);
}
42 changes: 0 additions & 42 deletions test/parallel/test-stream-base-prototype-accessors.js

This file was deleted.