Skip to content

MockService Doesn't Work with Services Defined as an ES6 Class #50

Description

@jongunter

This fails (apologies for the whitespace issues)

 class MyService {

        doAThing(){
            return 'bad';
        }

    }

////

        bard.appModule('app');

        bard.inject(this, 'MyService');
        bard.mockService(MyService, {
            _default: false
        });

    it('returns the proper values', ()=> {
        expect(MyService.doAThing()).toBe(false);
    })

Meanwhile, this succeeds:

  function MyService() {
        var returnBad = function () {
            return 'bad';
        };
        this.doAThing = returnBad;
    }

////

        bard.appModule('app');

        bard.inject(this, 'MyService');
        bard.mockService(MyService, {
            _default: false
        });

    it('returns the proper values', ()=> {
        expect(MyService.doAThing()).toBe(false);
    })

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions