Skip to content

Instantly share code, notes, and snippets.

@jdberrocal1
Last active August 6, 2021 21:09
Show Gist options
  • Select an option

  • Save jdberrocal1/2c1513c4c5589830c5514bfa258cdf01 to your computer and use it in GitHub Desktop.

Select an option

Save jdberrocal1/2c1513c4c5589830c5514bfa258cdf01 to your computer and use it in GitHub Desktop.
Ember Test Example (easy)
//Component thousand-limit-reached
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | thousand limit reached', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
await render(hbs`<ThousandLimitReached />`);
assert.dom('#thousand_limit_reached').exists('Component exists');
assert.dom('#thousand_limit_reached').containsText('Contact us to continue running reports today', 'Contact us title exists');
assert.dom('#thousand_limit_reached').containsText('We offer customized solutions for those who require more reports', 'Offer title exists');
assert.dom('.contact_modal .header').hasText('Email Us', 'Email us label exists');
});
test('when is pro user', async function (assert) {
const currentUserService = this.owner.lookup('service:current-user');
sinon.stub(currentUserService, 'isPro').get(function() { //Use .get when you are stubing a computed property
return true
});
await render(hbs`<ThousandLimitReached />`);
assert.dom('.contact_modal h1').hasText('accounts@beenverified.com', 'Shows accounts email');
});
test('when is not pro user', async function (assert) {
const currentUserService = this.owner.lookup('service:current-user');
sinon.stub(currentUserService, 'isPro').get(function() {
return false
});
await render(hbs`<ThousandLimitReached />`);
assert.dom('.contact_modal h1').hasText('support@beenverified.com', 'Shows support email');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment