Skip to content

Commit

Permalink
Skip tests for methods that don't exist (but include a failure).
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 8, 2015
1 parent fc618ea commit 8618bd1
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ var runArrayTests = function () {
});

describe('Array.from()', function () {
if (!Array.hasOwnProperty('from')) {
return it('exists', function () {
expect(Array).to.have.property('from');
});
}

it('has a length of 1', function () {
expect(Array.from.length).to.equal(1);
});
Expand Down Expand Up @@ -226,12 +232,24 @@ var runArrayTests = function () {
});

describe('Array.of()', function () {
if (!Array.hasOwnProperty('of')) {
return it('exists', function () {
expect(Array).to.have.property('of');
});
}

it('should create correct array from arguments', function () {
expect(Array.of(1, null, undefined)).to.eql([1, null, undefined]);
});
});

describe('Array#copyWithin', function () {
if (!Array.prototype.hasOwnProperty('copyWithin')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('copyWithin');
});
}

it('has the right arity', function () {
expect(Array.prototype.copyWithin.length).to.equal(2);
});
Expand Down Expand Up @@ -275,6 +293,12 @@ var runArrayTests = function () {
});

describe('Array#find', function () {
if (!Array.prototype.hasOwnProperty('find')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('find');
});
}

it('should have a length of 1', function () {
expect(Array.prototype.find.length).to.equal(1);
});
Expand Down Expand Up @@ -348,6 +372,12 @@ var runArrayTests = function () {
});

describe('Array#findIndex', function () {
if (!Array.prototype.hasOwnProperty('findIndex')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('findIndex');
});
}

it('should have a length of 1', function () {
expect(Array.prototype.findIndex.length).to.equal(1);
});
Expand Down Expand Up @@ -421,6 +451,12 @@ var runArrayTests = function () {
});

describe('ArrayIterator', function () {
if (!Array.prototype.hasOwnProperty('keys')) {
return it('can be tested', function () {
expect(Array.prototype).to.have.property('keys');
});
}

var arrayIterator;
beforeEach(function () {
arrayIterator = [1, 2, 3].values();
Expand All @@ -441,6 +477,12 @@ var runArrayTests = function () {
});

describe('Array#keys', function () {
if (!Array.prototype.hasOwnProperty('keys')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('keys');
});
}

it('should have a length of zero', function () {
expect(Array.prototype.keys.length).to.equal(0);
});
Expand Down Expand Up @@ -498,6 +540,12 @@ var runArrayTests = function () {
});

describe('Array#values', function () {
if (!Array.prototype.hasOwnProperty('values')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('values');
});
}

it('should have a length of zero', function () {
expect(Array.prototype.values.length).to.equal(0);
});
Expand Down Expand Up @@ -555,6 +603,12 @@ var runArrayTests = function () {
});

describe('Array#entries', function () {
if (!Array.prototype.hasOwnProperty('entries')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('entries');
});
}

it('should have a length of zero', function () {
expect(Array.prototype.entries.length).to.equal(0);
});
Expand Down Expand Up @@ -618,6 +672,12 @@ var runArrayTests = function () {
});

describe('Array#fill', function () {
if (!Array.prototype.hasOwnProperty('fill')) {
return it('exists', function () {
expect(Array.prototype).to.have.property('fill');
});
}

it('has the right length', function () {
expect(Array.prototype.fill.length).to.equal(1);
});
Expand Down
8 changes: 8 additions & 0 deletions test/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ describe('Collections', function () {
});

it('should have an iterator that works with Array.from', function () {
expect(Array).to.have.property('from');

expect(map.set('a', 1)).to.equal(map);
expect(map.set('b', NaN)).to.equal(map);
expect(map.set('c', false)).to.equal(map);
Expand Down Expand Up @@ -611,6 +613,12 @@ describe('Collections', function () {
});

describe('has an iterator that works with Array.from', function () {
if (!Array.hasOwnProperty('from')) {
return it('requires Array.from to exist', function () {
expect(Array).to.have.property('from');
});
}

var set;
beforeEach(function () {
set = new Set([1, NaN, false]);
Expand Down
6 changes: 6 additions & 0 deletions test/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ describe('Object', function (undefined) {
});

describe('Object.assign()', function () {
if (!Object.hasOwnProperty('assign')) {
return it('exists', function () {
expect(Object).to.have.property('assign');
});
}

it('has the correct length', function () {
expect(Object.assign.length).to.eql(2);
});
Expand Down
6 changes: 6 additions & 0 deletions test/reflect.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ var ifFreezeIt = typeof Object.freeze === 'function' ? it : xit;
var ifFunctionNamesIt = functionsHaveNames ? it : xit;

describe('Reflect', function () {
if (typeof Reflect === 'undefined') {
return it('exists', function () {
expect(this).to.have.property('Reflect');
});
}

var object = {
something: 1,
_value: 0
Expand Down
6 changes: 6 additions & 0 deletions test/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ describe('RegExp', function () {
});

describeIfSupportsDescriptors('#flags', function () {
if (!RegExp.prototype.hasOwnProperty('flags')) {
return it('exists', function () {
expect(RegExp.prototype).to.have.property('flags');
});
}

var regexpFlagsDescriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
var testGenericRegExpFlags = function (object) {
return regexpFlagsDescriptor.get.call(object);
Expand Down
54 changes: 54 additions & 0 deletions test/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ var runStringTests = function () {
});

describe('#repeat()', function () {
if (!String.prototype.hasOwnProperty('repeat')) {
return it('exists', function () {
expect(String.prototype).to.have.property('repeat');
});
}

it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('repeat');
});
Expand Down Expand Up @@ -53,6 +59,12 @@ var runStringTests = function () {
});

describe('#startsWith()', function () {
if (!String.prototype.hasOwnProperty('startsWith')) {
return it('exists', function () {
expect(String.prototype).to.have.property('startsWith');
});
}

it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('startsWith');
});
Expand Down Expand Up @@ -138,6 +150,12 @@ var runStringTests = function () {
});

describe('#endsWith()', function () {
if (!String.prototype.hasOwnProperty('endsWith')) {
return it('exists', function () {
expect(String.prototype).to.have.property('endsWith');
});
}

it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('endsWith');
});
Expand Down Expand Up @@ -226,6 +244,12 @@ var runStringTests = function () {
});

describe('#includes()', function () {
if (!String.prototype.hasOwnProperty('includes')) {
return it('exists', function () {
expect(String.prototype).to.have.property('includes');
});
}

it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('includes');
});
Expand Down Expand Up @@ -296,6 +320,12 @@ var runStringTests = function () {
});

describe('.fromCodePoint()', function () {
if (!String.hasOwnProperty('fromCodePoint')) {
return it('exists', function () {
expect(String).to.have.property('fromCodePoint');
});
}

it('throws a RangeError', function () {
var invalidValues = [
'abc',
Expand Down Expand Up @@ -334,6 +364,12 @@ var runStringTests = function () {
});

describe('#codePointAt()', function () {
if (!String.prototype.hasOwnProperty('codePointAt')) {
return it('exists', function () {
expect(String.prototype).to.have.property('codePointAt');
});
}

it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('codePointAt');
});
Expand Down Expand Up @@ -363,6 +399,12 @@ var runStringTests = function () {
});

describe('#iterator()', function () {
if (!Array.hasOwnProperty('from')) {
return it('requires Array.from to test', function () {
expect(Array).to.have.property('from');
});
}

it('should work with plain strings', function () {
var str = 'abc';
expect(Array.from(str)).to.eql(['a', 'b', 'c']);
Expand All @@ -377,6 +419,12 @@ var runStringTests = function () {
});

describe('.raw()', function () {
if (!String.hasOwnProperty('raw')) {
return it('exists', function () {
expect(String).to.have.property('raw');
});
}

it('should have a length of 1', function () {
expect(String.raw.length).to.equal(1);
});
Expand Down Expand Up @@ -421,6 +469,12 @@ var runStringTests = function () {
});

describe('#trim()', function () {
if (!String.prototype.hasOwnProperty('trim')) {
return it('exists', function () {
expect(String.prototype).to.have.property('trim');
});
}

it('should trim the correct characters', function () {
var whitespace = '\u0009' + '\u000b' + '\u000c' + '\u0020' +
'\u00a0' + '\u1680' + '\u2000' + '\u2001' +
Expand Down

0 comments on commit 8618bd1

Please sign in to comment.