# Code coverage report for modules/__tests__/Disposable-test.js

## Statements: 100% (32 / 32) Branches: 75% (3 / 4) Functions: 100% (9 / 9) Lines: 100% (31 / 31) Ignored: none

All files » modules/__tests__/ » Disposable-test.js

    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

    2

    1

    1

    1

    1

    1
    1
    1

    1
    1
    1
    1

    1
    1
    1

    1
    1
    1
    1

    1
    1

    1
    1
    1
    1

    1
    1
    1

    1
    1
    1

     'use strict';

    var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };

    var _expect = require('expect.js');

    var _expect2 = _interopRequireWildcard(_expect);

    var _Disposable = require('../Disposable');

    var _Disposable2 = _interopRequireWildcard(_Disposable);

    describe('Disposable', function () {
      it('should provide empty disposable', function () {
        _expect2['default'](_Disposable2['default'].empty.dispose).to.not.throwError();
      });

      it('calls dispose', function () {
        var disposed = false;
        var d = new _Disposable2['default'](function () {
          return disposed = true;
        });
        _expect2['default'](disposed).to.equal(false);
        d.dispose();
        _expect2['default'](disposed).to.equal(true);
      });

      it('calls dispose with null context', function () {
        var context = undefined;
        var d = new _Disposable2['default'](function () {
          context = this;
        });
        d.dispose();
        _expect2['default'](context).to.equal(null);
      });

      it('does not call dispose twice', function () {
        var disposed = false;
        var d = new _Disposable2['default'](function () {
          return disposed = true;
        });
        _expect2['default'](disposed).to.equal(false);
        d.dispose();
        _expect2['default'](disposed).to.equal(true);

        disposed = 42;
        d.dispose();
        _expect2['default'](disposed).to.equal(42);
      });
    });
    //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9kYW4vRG9jdW1lbnRzL1Byb2plY3RzL2Rpc3Bvc2FibGVzL21vZHVsZXMvX190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