I am moving away from ember-macro-helpers/computed in my project and starting using computed from '@ember/object'
I have following code
rowData: computed('addEndpointsData', function () {
const addEndpointsData = this.addEndpointsData
const data = this._getEndpointGridData(addEndpointsData)
if (data) {
this.endpointRows.push(data)
this.set('endpoints', this.endpointRows)
return this.endpoints
}
}).readOnly(),
endpointSummaryMsg: computed('rowData', 'endpoints.[]', function () {
const endpoints = getWithDefault(this, 'endpoints', [])
return `${endpoints.length} Endpoint(s)`
}).readOnly(),
And in my test case, I am setting addEndpointsData so that rowData gets re-computed and in turn endpointSummaryMsg.
describe('when add endpoint data is not empty', function () {
beforeEach(function () {
component.setProperties({
endpoints: [],
tmpEndpoints: [],
actionType: ACTION_ENUM.ADD,
endpointRows: [],
addEndpointsData: {
serviceIntent: {
properties: {
endpoints: [{
settings: {
role: 'UNI'
}
}],
serviceType: 'EVPL'
}
}
},
onEndpointChange () {}
})
})
it('should display right summary msg for one rows', function () {
expect(component.get('endpointSummaryMsg')).to.eql('1 Endpoint(s)')
})
})
})
It was working fine with macro-helper, but with ember/objects, this seems to break and rowData is not re-computed, hence testcase gets 0 Endpoint(s)
I have tried following
. set(addEndpointsData, 'serviceIntent', {....})
. component.notifyPropertyChange('addEndpointsData')
but nothing seems to work. What could be the issue here?