Skip to content

Commit

Permalink
Minor inspect code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Dec 23, 2015
1 parent 650c612 commit 4483a81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
13 changes: 5 additions & 8 deletions lib/chai/utils/inspect.js
Expand Up @@ -8,7 +8,7 @@ var getEnumerableProperties = require('./getEnumerableProperties');
module.exports = inspect;

/**
* Echos the value of a value. Trys to print the value out
* Echos the value of a value. Tries to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
Expand Down Expand Up @@ -231,6 +231,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
output.push('');
}
}

keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
Expand All @@ -244,10 +245,7 @@ function formatTypedArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];

// Truncating TypedArray if it has more than 1000 elements
var l = value.length;
if (l > 1000) {
l = 5
}
var l = value.length > 1000 ? 5 : value.length;

for (var i = 0; i < l; ++i) {
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
Expand All @@ -258,7 +256,7 @@ function formatTypedArray(ctx, value, recurseTimes, visibleKeys, keys) {
}
}

// If TypedArray has been truncated we add '...' to it's end
// If TypedArray has been truncated we add '...' to its end
if (l !== value.length) {
output.push('...');
}
Expand Down Expand Up @@ -358,8 +356,7 @@ function isTypedArray(ar) {
objectToString(ar) === '[object Int32Array]' ||
objectToString(ar) === '[object Uint32Array]' ||
objectToString(ar) === '[object Float32Array]' ||
objectToString(ar) === '[object Float64Array]'
)
objectToString(ar) === '[object Float64Array]');
}

function isArray(ar) {
Expand Down
9 changes: 4 additions & 5 deletions test/utilities.js
Expand Up @@ -391,7 +391,7 @@ describe('utilities', function () {
});
});

it('inspect typedArray conversion', function () {
it('inspect every kind of available TypedArray', function () {
chai.use(function (_chai, _) {
var arr = [1, 2, 3]
, exp = '[ 1, 2, 3 ]'
Expand Down Expand Up @@ -427,7 +427,7 @@ describe('utilities', function () {
});
});

it('truncate long typedArray', function () {
it('truncate long TypedArray', function () {
chai.use(function (_chai, _) {

var arr = []
Expand All @@ -445,9 +445,8 @@ describe('utilities', function () {

if ((!isNode && 'Int8Array' in window) ||
isNode && typeof 'Int8Array' !== undefined) {

expect(_.inspect(new Int8Array(arr))).to.equal(exp);
}
expect(_.inspect(new Int8Array(arr))).to.equal(exp);
}
});
});

Expand Down

0 comments on commit 4483a81

Please sign in to comment.