|
|
@@ -270,7 +270,7 @@ describe('Observer', function () {
|
|
|
|
|
|
describe('Augmentations', function () {
|
|
|
|
|
|
- it('remove (index)', function () {
|
|
|
+ it('$remove (index)', function () {
|
|
|
var emitted = false,
|
|
|
index = ~~(Math.random() * arr.length),
|
|
|
expected = arr[index] = { a: 1 }
|
|
|
@@ -280,12 +280,12 @@ describe('Observer', function () {
|
|
|
assert.strictEqual(mutation.args.length, 2)
|
|
|
assert.strictEqual(mutation.args[0], index)
|
|
|
})
|
|
|
- var r = arr.remove(index)
|
|
|
+ var r = arr.$remove(index)
|
|
|
assert.ok(emitted)
|
|
|
assert.strictEqual(r, expected)
|
|
|
})
|
|
|
|
|
|
- it('remove (object)', function () {
|
|
|
+ it('$remove (object)', function () {
|
|
|
var emitted = false,
|
|
|
index = ~~(Math.random() * arr.length),
|
|
|
expected = arr[index] = { a: 1 }
|
|
|
@@ -295,12 +295,12 @@ describe('Observer', function () {
|
|
|
assert.strictEqual(mutation.args.length, 2)
|
|
|
assert.strictEqual(mutation.args[0], index)
|
|
|
})
|
|
|
- var r = arr.remove(expected)
|
|
|
+ var r = arr.$remove(expected)
|
|
|
assert.ok(emitted)
|
|
|
assert.strictEqual(r, expected)
|
|
|
})
|
|
|
|
|
|
- it('remove (function)', function () {
|
|
|
+ it('$remove (function)', function () {
|
|
|
var expected = [1001, 1002]
|
|
|
arr.push.apply(arr, expected)
|
|
|
var filter = function (e) {
|
|
|
@@ -309,12 +309,12 @@ describe('Observer', function () {
|
|
|
copy = arr.filter(function (e) {
|
|
|
return e <= 1000
|
|
|
})
|
|
|
- var removed = arr.remove(filter)
|
|
|
+ var removed = arr.$remove(filter)
|
|
|
assert.deepEqual(arr, copy)
|
|
|
assert.deepEqual(expected, removed)
|
|
|
})
|
|
|
|
|
|
- it('replace (index)', function () {
|
|
|
+ it('$replace (index)', function () {
|
|
|
var emitted = false,
|
|
|
index = ~~(Math.random() * arr.length),
|
|
|
expected = arr[index] = { a: 1 },
|
|
|
@@ -325,13 +325,13 @@ describe('Observer', function () {
|
|
|
assert.strictEqual(mutation.args.length, 3)
|
|
|
assert.strictEqual(mutation.args[0], index)
|
|
|
})
|
|
|
- var r = arr.replace(index, arg)
|
|
|
+ var r = arr.$replace(index, arg)
|
|
|
assert.ok(emitted)
|
|
|
assert.strictEqual(r, expected)
|
|
|
assert.strictEqual(arr[index], arg)
|
|
|
})
|
|
|
|
|
|
- it('replace (object)', function () {
|
|
|
+ it('$replace (object)', function () {
|
|
|
var emitted = false,
|
|
|
index = ~~(Math.random() * arr.length),
|
|
|
expected = arr[index] = { a: 1 },
|
|
|
@@ -342,19 +342,19 @@ describe('Observer', function () {
|
|
|
assert.strictEqual(mutation.args.length, 3)
|
|
|
assert.strictEqual(mutation.args[0], index)
|
|
|
})
|
|
|
- var r = arr.replace(expected, arg)
|
|
|
+ var r = arr.$replace(expected, arg)
|
|
|
assert.ok(emitted)
|
|
|
assert.strictEqual(r, expected)
|
|
|
assert.strictEqual(arr[index], arg)
|
|
|
})
|
|
|
|
|
|
- it('replace (function)', function () {
|
|
|
+ it('$replace (function)', function () {
|
|
|
arr[0] = 1
|
|
|
arr[1] = 2
|
|
|
arr[2] = 3
|
|
|
var expected = [2, 3, 3],
|
|
|
expectRet = [1, 2]
|
|
|
- var replaced = arr.replace(function (e) {
|
|
|
+ var replaced = arr.$replace(function (e) {
|
|
|
if (e < 3) return e + 1
|
|
|
})
|
|
|
assert.deepEqual(arr, expected)
|