Skip to content

breakpoints aren't available in unit tests #114

Description

@mminkoff

I need to include the media service in my application controller unit test. However, as a unit test it doesn't get an application and so the breakpoints module isn't available (which took me about a day to realize). That's my bad. The solution was to also include 'breakpoints:main' in needs.

However, the error message is, as you might guess from the day-long diagnosis, not so helpful. Here's the problematic part:

// from tests/helpers/responsive.js
  _breakpointArr: Ember.computed('breakpoints', function() {
    return Object.keys(this.get('breakpoints')) || Ember.A([]);
  }),

I'm not entirely sure what the intention is or I'd submit a pull request.

First, I'd throw a more meaningful error if isBlank(this.get('breakpoints')), perhaps wondering if it's being included in a unit test and suggesting my fix above.

Second, I wonder what circumstances would allow the second half of the || to be reached. Even if it is, Object.keys wouldn't have returned an Ember.A, would it? So why the Ember.A here?

Thanks for taking a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions