Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ember-sinon-qunit (New)
- // test-helper.js
- import { setApplication } from '@ember/test-helpers';
- import { start } from 'ember-qunit';
- import Application from '../app';
- import config from '../config/environment';
- import setupSinon from 'ember-sinon-qunit';
- setApplication(Application.create(config.APP));
- setupSinon();
- start();
- // foo-test.js
- import { module, test } from 'ember-qunit';
- import sinon from 'sinon';
- module('Foo Test', function (hooks) {
- hooks.beforeEach(function () {
- // setup 'this.foo'
- this.barSpy = sinon.spy(this.foo, 'bar');
- });
- });
- test('bar was called', function (assert) {
- this.foo.bar();
- assert.ok(this.barSpy.calledOnce, 'bar was called');
- });
- /**************************/
- // ember-sinon-qunit (Old)
- // foo-test.js
- import { module } from 'ember-qunit';
- import test from 'ember-sinon-qunit/test-support/test;
- module('Foo Test', function (hooks) {
- hooks.beforeEach(function () {
- // setup 'this.foo'
- this.barSpy = this.spy(this.foo, 'bar');
- });
- });
- test('bar was called', function (assert) {
- this.foo.bar();
- assert.ok(this.barSpy.calledOnce, 'bar was called');
- });
- /**************************/
- // ember-sinon-sandbox
- // foo-test.js
- import { module, test } from 'ember-qunit';
- import { setupSinonSandbox } from 'ember-sinon-sandbox/test-support';
- module('Foo Test', function (hooks) {
- setupSinonSandbox(hooks);
- hooks.beforeEach(function () {
- // setup 'this.foo'
- this.barSpy = this.sandbox.spy(this.foo, 'bar');
- });
- });
- test('bar was called', function (assert) {
- this.foo.bar();
- assert.ok(this.barSpy.calledOnce, 'bar was called');
- });
- /**************************/
- // ember-sinon-sinoff
- // foo-test.js
- import { module, test } from 'ember-qunit';
- import { setupSinonSinoff } from 'ember-sinon-sinoff/test-support';
- module('Foo Test', function (hooks) {
- setupSinonSinoff(hooks);
- hooks.beforeEach(function () {
- // setup 'this.foo'
- this.barSpy = this.sandbox.spy(this.foo, 'bar');
- });
- });
- test('bar was called', function (assert) {
- this.foo.bar();
- assert.ok(this.barSpy.calledOnce, 'bar was called');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement