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

43.75% Statements 14/32
50% Branches 1/2
15.79% Functions 3/19
43.75% Lines 14/32

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  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, exists, assertJSON } = require('./helpers');
 
describe('Acceptance', function() {
  describe('browserconfig', function() {
    this.timeout(300000);
 
    let app;
 
    before(function() {
      Eif (process.env.SKIP_ACCEPTANCE === 'true') {
        this.skip();
        return;
      }
 
      app = new AddonTestApp();
    });
 
    it('generates a browserconfig.xml file', function() {
      return app
        .create('empty', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(() => app.runEmberCommand('build'))
        .then(contentOf(app, 'dist/browserconfig.xml'))
        .then(content =>
          assert.strictEqual(
            content,
            '<?xml version="1.0"?><browserconfig><msapplication/></browserconfig>'
          )
        );
    });
 
    it('configures broccoli-asset-rev', function() {
      return app
        .create('dummy', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(() => app.runEmberCommand('build', '--prod'))
        .then(contentOf(app, 'dist/browserconfig.xml'))
        .then(content =>
          assert.strictEqual(
            content,
            '<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="pio-8911090226e7b5522790f1218f6924a5.png"/><TileColor>#FFFFFF</TileColor></tile></msapplication></browserconfig>'
          )
        )
        .then(contentOf(app, 'dist/fastbootAssetMap.json'))
        .then(assertJSON(app, { 'pio.png': 'pio-0987654321.png' }));
    });
 
    it(`doesn't generate browserconfig when tag is omitted`, function() {
      return app
        .create('no-browserconfig', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(() => app.runEmberCommand('build'))
        .then(() =>
          assert.ok(
            !exists(app, 'dist/browserconfig.xml'),
            `Doesn't generate browserconfig.xml file`
          )
        )
        .then(contentOf(app, 'dist/index.html'))
        .then(content =>
          assert.ok(
            !content.includes('msapplication-config'),
            `Doesn't include meta tags`
          )
        );
    });
 
    it('uses rootURL configuration', function() {
      return app
        .create('config-root-url', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(() => app.runEmberCommand('build'))
        .then(contentOf(app, 'dist/index.html'))
        .then(content =>
          assert.ok(
            content.indexOf('content="/foo/bar/baz/browserconfig.xml"') > -1,
            'index.html uses rootURL from configuration'
          )
        );
    });
 
    it('uses fingerprint configuration for browserconfig', function() {
      return app
        .create('broccoli-asset-rev', {
          fixturesPath: 'node-tests/acceptance/fixtures',
        })
        .then(() => app.runEmberCommand('build', '--prod'))
        .then(contentOf(app, 'dist/browserconfig.xml'))
        .then(content =>
          assert.strictEqual(
            content,
            '<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png"/><TileColor>#FFFFFF</TileColor></tile></msapplication></browserconfig>'
          )
        );
    });
  });
});