github.com/hernad/nomad@v1.6.112/ui/tests/integration/components/policy-editor-test.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { module, test } from 'qunit';
     7  import { setupRenderingTest } from 'ember-qunit';
     8  import { render } from '@ember/test-helpers';
     9  import { hbs } from 'ember-cli-htmlbars';
    10  import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
    11  
    12  module('Integration | Component | policy-editor', function (hooks) {
    13    setupRenderingTest(hooks);
    14  
    15    test('it renders', async function (assert) {
    16      assert.expect(1);
    17      await render(hbs`<PolicyEditor />`);
    18      await componentA11yAudit(this.element, assert);
    19    });
    20  
    21    test('Only has editable name if new', async function (assert) {
    22      const newMockPolicy = {
    23        isNew: true,
    24        name: 'New Policy',
    25      };
    26  
    27      const oldMockPolicy = {
    28        isNew: false,
    29        name: 'Old Policy',
    30      };
    31  
    32      this.set('newMockPolicy', newMockPolicy);
    33      this.set('oldMockPolicy', oldMockPolicy);
    34  
    35      await render(hbs`<PolicyEditor @policy={{this.newMockPolicy}} />`);
    36      assert.dom('[data-test-policy-name-input]').exists();
    37      await render(hbs`<PolicyEditor @policy={{this.oldMockPolicy}} />`);
    38      assert.dom('[data-test-policy-name-input]').doesNotExist();
    39    });
    40  });