Permalink
Browse files

Make .remove chainable

  • Loading branch information...
1 parent bd1065f commit 51b60f1257e35a5ec57fb8c2d4c48d858c580558 @DarthJDG committed Sep 5, 2016
Showing with 7 additions and 14 deletions.
  1. +2 −5 mangler.js
  2. +5 −9 test/test.js
View
@@ -1127,11 +1127,8 @@ var Mangler = (function(global) {
remove: function(item) {
var i = this.items.indexOf(item);
- if(i > -1) {
- this.items.splice(i, 1);
- return true;
- }
- return false;
+ if(i > -1) this.items.splice(i, 1);
+ return this;
},
rename: function(dict) {
View
@@ -1206,18 +1206,14 @@
});
QUnit.test('.remove', function(assert) {
- assert.expect(8);
+ assert.expect(4);
var m = Mangler(['A', 'B', 'C']);
- assert.strictEqual(m.remove('B'), true, 'passed');
- assert.deepEqual(m.items, ['A', 'C'], 'passed');
- assert.strictEqual(m.remove('D'), false, 'passed');
- assert.deepEqual(m.items, ['A', 'C'], 'passed');
- assert.strictEqual(m.remove('A'), true, 'passed');
- assert.deepEqual(m.items, ['C'], 'passed');
- assert.strictEqual(m.remove('C'), true, 'passed');
- assert.deepEqual(m.items, [], 'passed');
+ assert.deepEqual(m.remove('B').items, ['A', 'C'], 'passed');
+ assert.deepEqual(m.remove('D').items, ['A', 'C'], 'passed');
+ assert.deepEqual(m.remove('A').items, ['C'], 'passed');
+ assert.deepEqual(m.remove('C').items, [], 'passed');
});
QUnit.test('.rename', function(assert) {

0 comments on commit 51b60f1

Please sign in to comment.