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

100% Statements 22/22
100% Branches 0/0
100% Functions 11/11
100% Lines 20/20

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  1x 1x       4x 4x       4x       1x 1x 1x 1x 1x   1x           1x 1x                   1x     1x 1x                     1x     1x 1x                                     1x                
'use strict';
const assert = require('assert');
const Browserconfig = require('../../../lib/browserconfig');
 
class TestBrowserconfig extends Browserconfig {
  constructor(configuration) {
    super({});
    this._configuration = configuration;
  }
 
  get configuration() {
    return this._configuration;
  }
}
 
describe('Unit', function() {
  describe('browserconfig', function() {
    describe('generate()', function() {
      it(`generates the minimal browserconfig.xml if there are no icons with 'ms' target`, function() {
        let browserconfig = new TestBrowserconfig({});
 
        assert.strictEqual(
          browserconfig.generate(),
          '<?xml version="1.0"?><browserconfig><msapplication/></browserconfig>'
        );
      });
 
      it(`throws an error if it finds an icon with target 'ms' without the right 'element' property`, function() {
        let browserconfig = new TestBrowserconfig({
          icons: [
            {
              src: 'image.png',
              sizes: '150x150',
              targets: ['ms'],
            },
          ],
        });
 
        assert.throws(() => browserconfig.generate());
      });
 
      it(`throws an error if the icon is valid but there's no 'ms.tileColor' property`, function() {
        let browserconfig = new TestBrowserconfig({
          icons: [
            {
              src: 'image.png',
              sizes: '150x150',
              element: 'square150x150logo',
              targets: ['ms'],
            },
          ],
        });
 
        assert.throws(() => browserconfig.generate());
      });
 
      it(`adds each icon to the list of tiles`, function() {
        let browserconfig = new TestBrowserconfig({
          icons: [
            {
              src: 'mstile-150x150.png',
              element: 'square150x150logo',
              targets: ['ms'],
            },
            {
              src: 'mstile-310x310.png',
              element: 'square310x310logo',
              targets: ['ms'],
            },
          ],
 
          ms: {
            tileColor: '#ffffff',
          },
        });
 
        assert.strictEqual(
          browserconfig.generate(),
          `<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="mstile-150x150.png"/><square310x310logo src="mstile-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>`
        );
      });
    });
  });
});