github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/unit/mixins/intention/with-actions-test.js (about)

     1  import { moduleFor } from 'ember-qunit';
     2  import test from 'ember-sinon-qunit/test-support/test';
     3  import { getOwner } from '@ember/application';
     4  import Route from '@ember/routing/route';
     5  import Mixin from 'consul-ui/mixins/intention/with-actions';
     6  
     7  moduleFor('mixin:intention/with-actions', 'Unit | Mixin | intention/with actions', {
     8    // Specify the other units that are required for this test.
     9    needs: [
    10      'mixin:with-blocking-actions',
    11      'service:feedback',
    12      'service:flashMessages',
    13      'service:logger',
    14    ],
    15    subject: function() {
    16      const MixedIn = Route.extend(Mixin);
    17      this.register('test-container:intention/with-actions-object', MixedIn);
    18      return getOwner(this).lookup('test-container:intention/with-actions-object');
    19    },
    20  });
    21  
    22  // Replace this with your real tests.
    23  test('it works', function(assert) {
    24    const subject = this.subject();
    25    assert.ok(subject);
    26  });
    27  test('errorCreate returns a different status code if a duplicate intention is found', function(assert) {
    28    const subject = this.subject();
    29    const expected = 'exists';
    30    const actual = subject.errorCreate('error', {
    31      errors: [{ status: '500', detail: 'duplicate intention found:' }],
    32    });
    33    assert.equal(actual, expected);
    34  });
    35  test('errorCreate returns the same code if there is no error', function(assert) {
    36    const subject = this.subject();
    37    const expected = 'error';
    38    const actual = subject.errorCreate('error', {});
    39    assert.equal(actual, expected);
    40  });