Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-owner-test-utils

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-owner-test-utils

The default blueprint for ember-cli addons.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

Ember Owner Test Utils

Build Status Ember Observer Score

This is an addon that is intended to provide an easy mechanism to access and override Ember owner APIs.

Installation

ember install ember-owner-test-utils

Usage

Register

I find this is most useful for dealin with services that hit the network. It allows you to declaratively specify what a given registration is responsible for inside the test file itself.

At the top of your acceptance|integration|unit test import the register helper with the following line:

import { register } from 'ember-owner-test-utils/test-support/register';

Then from within any place that has a test context (ie inside a beforeEach or test) you may set a new registration with the following:

test('it calls foo on the foo service', function(assert){
  assert.expect(1);

  register(this, 'service:foo', Ember.Service.extend({
    foo() {
      assert.ok(true);
    }
  }));

  visit('/thing');
  click('.foo-button-that-triggers-expected-service');
});

This signature can be used in all forms of Ember tests.

Playing Make Believe

You can even use it to make a registration on a component that never existed. Like so:

// See here for more of the test:
// https://github.com/rondale-sc/ember-owner-test-utils/blob/master/tests/integration/my-component-test.js
test('allows the registration of components', function(assert) {
  assert.expect(1);

 register(this, 'template:components/my-component', hbs`<button class="do-it" {{ action 'foo' }}>GO!</button>`);

  register(this, 'component:my-component', Component.extend({
      actions: {
        foo() { assert.ok(true); }
      }
    })
  );

  this.render(hbs`{{my-component}}`);

  this.$('button').click();
});

Hat tip (🎩) to ember-route-action-helper on this one. This is very useful for testing complex interactions without needing to create unnecessary files in your addon's dummy folder.

Thanks

Special thanks to @rwjblue for help with 1.13.13 support. Was a difficult thing to track down. :beers: If you'd like to hear @cowboyd and myself talk about this in more depth you can check it out at this episode of ember weekend:

Ember Weekend: Bug Integrat

Keywords

FAQs

Package last updated on 18 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc