Code coverage report for app/pages/phone/add/phone-add.controller.js

Statements: 100% (36 / 36)      Branches: 100% (10 / 10)      Functions: 100% (9 / 9)      Lines: 100% (12 / 12)      Ignored: 2 statements, 4 branches     

All files » app/pages/phone/add/ » phone-add.controller.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  1 3   3 3         2       1 1     1 1 1         1        
class PhoneAddController {
    constructor (PhoneAPI, $state, $q, Modal) {
        Object.assign(this, {PhoneAPI, $state, $q, Modal});
 
        this.phone = {};
        this.state = 'add';
    }
 
    addNewPhone (ctrl, phone) {
        // return promise here to let the phone form controller know the response status
        return ctrl.PhoneAPI.addNewPhone(phone)
            .then(_success)
            .catch(_error);
 
        function _success () {
            ctrl.$state.go('root.layout.phone');
        }
 
        function _error (message) {
            ctrl.Modal.open('Add phone error', message.text, {ok: 'OK'});
            return ctrl.$q.reject();
        }
    }
}
 
PhoneAddController.$inject = ['PhoneAPI', '$state', '$q', 'Modal'];
 
export default PhoneAddController;