All files / ember-web-app/node-tests/unit/manifest configure-fingerprint-test.js

100% Statements 30/30
100% Branches 1/1
100% Functions 10/10
100% Lines 30/30

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  1x 1x       5x 5x       5x       1x 1x 1x 1x 1x 1x   1x     1x 1x 1x   1x     1x 1x     1x   1x         1x 1x           1x 1x   1x             1x 1x       1x 1x   1x                
'use strict';
const assert = require('assert');
const Manifest = require('../../../lib/manifest');
 
class TestManifest extends Manifest {
  constructor(app, required = true) {
    super(app, {});
    this.required = required;
  }
 
  get isRequired() {
    return this.required;
  }
}
 
describe('Unit', function() {
  describe('manifest', function() {
    describe('configureFingerprint()', function() {
      it('does nothing when is not required', function() {
        let manifest = new TestManifest({ options: {} }, false);
        manifest.configureFingerprint();
 
        assert.deepStrictEqual(manifest.app.options.fingerprint, undefined);
      });
 
      it('does nothing when fingerprinting is disabled', function() {
        let manifest = new TestManifest({ options: { fingerprint: false } });
        manifest.configureFingerprint();
 
        assert.strictEqual(manifest.app.options.fingerprint, false);
      });
 
      it('configures when options is undefined', function() {
        let manifest = new TestManifest({
          options: { fingerprint: undefined },
        });
        manifest.configureFingerprint();
 
        assert.deepStrictEqual(manifest.app.options.fingerprint, {
          replaceExtensions: ['html', 'css', 'js', 'webmanifest'],
        });
      });
 
      it('updates options', function() {
        let fingerprint = {
          prepend: 'prefix',
          exclude: ['foo', 'bar'],
          replaceExtensions: ['baz'],
        };
 
        let manifest = new TestManifest({ options: { fingerprint } });
        manifest.configureFingerprint();
 
        assert.deepStrictEqual(manifest.app.options.fingerprint, {
          prepend: 'prefix',
          exclude: ['foo', 'bar'],
          replaceExtensions: ['baz', 'webmanifest'],
        });
      });
 
      it('completes missing values using defaults', function() {
        let fingerprint = {
          prepend: 'prefix',
        };
 
        let manifest = new TestManifest({ options: { fingerprint } });
        manifest.configureFingerprint();
 
        assert.deepStrictEqual(manifest.app.options.fingerprint, {
          prepend: 'prefix',
          replaceExtensions: ['html', 'css', 'js', 'webmanifest'],
        });
      });
    });
  });
});