diff --git a/addon/array/map.js b/addon/array/map.js index 1668dd5..fa99bd3 100644 --- a/addon/array/map.js +++ b/addon/array/map.js @@ -1,5 +1,5 @@ import { normalizeArray } from './-utils'; -export default normalizeArray({}, (array, callback) => { - return array.map(callback); +export default normalizeArray({}, function(array, callback) { + return array.map((...args) => callback.apply(this, args)); }); diff --git a/tests/integration/array/map-test.js b/tests/integration/array/map-test.js index 115f32a..72ea1da 100644 --- a/tests/integration/array/map-test.js +++ b/tests/integration/array/map-test.js @@ -27,6 +27,19 @@ test('it maps array', function(assert) { }); }); +test('context is correct', function(assert) { + let callback = sinon.spy(); + + let { subject } = compute({ + computed: map('array', callback), + properties: { + array: [0] + } + }); + + assert.strictEqual(callback.thisValues[0], subject); +}); + test('it responds to array property value changes', function(assert) { let array = emberA([ EmberObject.create({ prop: false }),