github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/tests/helpers/module-for-job.js (about)

     1  import { test } from 'qunit';
     2  import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
     3  import JobDetail from 'nomad-ui/tests/pages/jobs/detail';
     4  
     5  export default function moduleForJob(title, jobFactory, additionalTests) {
     6    let job;
     7  
     8    moduleForAcceptance(title, {
     9      beforeEach() {
    10        server.create('node');
    11        job = jobFactory();
    12        JobDetail.visit({ id: job.id });
    13      },
    14    });
    15  
    16    test('visiting /jobs/:job_id', function(assert) {
    17      assert.equal(currentURL(), `/jobs/${job.id}`);
    18    });
    19  
    20    test('the subnav links to overview', function(assert) {
    21      JobDetail.tabFor('overview').visit();
    22      andThen(() => {
    23        assert.equal(currentURL(), `/jobs/${job.id}`);
    24      });
    25    });
    26  
    27    test('the subnav links to definition', function(assert) {
    28      JobDetail.tabFor('definition').visit();
    29      andThen(() => {
    30        assert.equal(currentURL(), `/jobs/${job.id}/definition`);
    31      });
    32    });
    33  
    34    test('the subnav links to versions', function(assert) {
    35      JobDetail.tabFor('versions').visit();
    36      andThen(() => {
    37        assert.equal(currentURL(), `/jobs/${job.id}/versions`);
    38      });
    39    });
    40  
    41    test('the subnav links to evaluations', function(assert) {
    42      JobDetail.tabFor('evaluations').visit();
    43      andThen(() => {
    44        assert.equal(currentURL(), `/jobs/${job.id}/evaluations`);
    45      });
    46    });
    47  
    48    for (var testName in additionalTests) {
    49      test(testName, function(assert) {
    50        additionalTests[testName](job, assert);
    51      });
    52    }
    53  }