All files / ember-web-app/node-tests/acceptance manifest-test.js

45.16% Statements 14/31
50% Branches 1/2
18.75% Functions 3/16
45.16% Lines 14/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155  1x 1x 1x   1x 1x 1x       1x 1x 1x             1x                                             1x                                   1x                                 1x                                                                                 1x                                                                      
'use strict';
const assert = require('assert');
const { AddonTestApp } = require('ember-cli-addon-tests');
const { contentOf, assertJSON } = require('./helpers');
 
describe('Acceptance', function() {
  describe('manifest', function() {
    this.timeout(300000);
 
    let app;
 
    before(function() {
      Eif (process.env.SKIP_ACCEPTANCE === 'true') {
        this.skip();
        return;
      }
 
      app = new AddonTestApp();
    });
 
    it('generates a manifest.webmanifest file', function() {
      return app
        .create('empty', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(function() {
          return app.runEmberCommand('build');
        })
        .then(contentOf(app, 'dist/manifest.webmanifest'))
        .then(
          assertJSON(app, {
            name: 'empty',
            short_name: 'empty',
            description: '',
            start_url: '/',
            display: 'standalone',
            background_color: '#fff',
            theme_color: '#fff',
            icons: [],
          })
        );
    });
 
    it('configures broccoli-asset-rev', function() {
      return app
        .create('dummy', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(function() {
          return app.runEmberCommand('build', '--prod');
        })
        .then(contentOf(app, 'dist/manifest.webmanifest'))
        .then(
          assertJSON(app, {
            icons: [{ src: 'pio-8911090226e7b5522790f1218f6924a5.png' }],
          })
        )
        .then(contentOf(app, 'dist/fastbootAssetMap.json'))
        .then(assertJSON(app, { 'pio.png': 'pio-0987654321.png' }));
    });
 
    it('uses rootURL configuration', function() {
      return app
        .create('config-root-url', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(function() {
          return app.runEmberCommand('build');
        })
        .then(contentOf(app, 'dist/index.html'))
        .then(function(content) {
          assert.ok(
            content.indexOf('href="/foo/bar/baz/manifest.webmanifest"') > -1,
            'index.html uses rootURL from configuration'
          );
        });
    });
 
    it('uses fingerprint configuration for manifest', function() {
      return app
        .create('broccoli-asset-rev', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(function() {
          return app.runEmberCommand('build', '--prod');
        })
        .then(contentOf(app, 'dist/index.html'))
        .then(function(content) {
          assert.ok(
            content.indexOf(
              'href="https://www.example.com/manifest-f105f80557272f93397e34ea016e172d.webmanifest"'
            ) > -1,
            'checksum fingerprint is added to manifest.webmanifest file'
          );
          assert.ok(
            content.indexOf(
              'href="https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png"'
            ) > -1,
            'checksum fingerprint is added to image file'
          );
        })
        .then(
          contentOf(
            app,
            'dist/manifest-f105f80557272f93397e34ea016e172d.webmanifest'
          )
        )
        .then(
          assertJSON(app, {
            icons: [
              {
                src:
                  'https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png',
              },
            ],
          })
        );
    });
 
    it('uses rootURL and fingerprint configurations', function() {
      return app
        .create('root-url-fingerprint', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(function() {
          return app.runEmberCommand('build', '--prod');
        })
        .then(contentOf(app, 'dist/index.html'))
        .then(function(content) {
          assert.ok(
            content.indexOf('href="/dummy/manifest.webmanifest"') > -1,
            'checksum fingerprint is added to manifest.webmanifest file'
          );
          assert.ok(
            content.indexOf(
              'href="https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png"'
            ) > -1,
            'checksum fingerprint is added to image file'
          );
        })
        .then(contentOf(app, 'dist/manifest.webmanifest'))
        .then(
          assertJSON(app, {
            icons: [
              {
                src:
                  'https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png',
              },
            ],
          })
        );
    });
  });
});