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

Statements: 100% (37 / 37)      Branches: 100% (10 / 10)      Functions: 100% (9 / 9)      Lines: 100% (13 / 13)      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 31                                     
class PhoneAddController {
    constructor (PhoneAPI, $state, $q, Modal) {
        Object.assign(this, {PhoneAPI, $state, $q, Modal});
 
        this.phone = {};
        this.state = 'add';
    }
 
    addNewPhone (phone) {
        const self = this;
        // return promise here to let the phone form controller know the response status
        return this.PhoneAPI.addNewPhone(phone)
            .then(_success)
            .catch(_error);
 
        function _success () {
            self.$state.go('root.layout.phone');
        }
 
        function _error (message) {
            self.Modal.open('Add phone error', message.text, {ok: 'OK'});
            return self.$q.reject();
        }
    }
}
 
PhoneAddController.$inject = ['PhoneAPI', '$state', '$q', 'Modal'];
 
export default PhoneAddController;