text: "use strict";
  
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  
  var _restricted = _interopRequireDefault(require("../../../core/cache/restricted"));
  
  /*!
   * V4Fire Core
   * https://github.com/V4Fire/Core
   *
   * Released under the MIT license
   * https://github.com/V4Fire/Core/blob/master/LICENSE
   */
  describe('core/cache/restricted', () => {
    it('crud', () => {
      const cache = new _restricted.default();
      expect(cache.has('foo')).toBeFalse();
      expect(cache.set('foo', 1)).toBe(1);
      expect(cache.get('foo')).toBe(1);
      expect(cache.has('foo')).toBeTrue();
      expect(cache.size).toBe(1);
      expect(cache.remove('foo')).toBe(1);
      expect(cache.has('foo')).toBeFalse();
    });
    it('specifying capacity', () => {
      const cache = new _restricted.default(3);
      cache.set('foo', 1);
      cache.set('bar', 2);
      cache.set('bla', 3);
      expect(cache.has('foo')).toBeTrue();
      expect(cache.has('bar')).toBeTrue();
      expect(cache.has('bla')).toBeTrue();
      cache.set('baz', 4);
      expect(cache.size).toBe(3);
      expect(cache.has('foo')).toBeFalse();
      expect(cache.has('baz')).toBeTrue();
    });
    it('default iterator', () => {
      const cache = new _restricted.default(2);
      cache.set('1', 1);
      cache.set('2', 2);
      cache.set('3', 3);
      expect(cache[Symbol.iterator]().next()).toEqual({
        value: '2',
        done: false
      });
      expect([...cache]).toEqual(['2', '3']);
    });
    it('`keys`', () => {
      const cache = new _restricted.default(2);
      cache.set('1', 1);
      cache.set('2', 2);
      cache.set('3', 3);
      expect([...cache.keys()]).toEqual(['2', '3']);
    });
    it('`values`', () => {
      const cache = new _restricted.default(2);
      cache.set('1', 1);
      cache.set('2', 2);
      cache.set('3', 3);
      expect([...cache.values()]).toEqual([2, 3]);
    });
    it('`entries`', () => {
      const cache = new _restricted.default(2);
      cache.set('1', 1);
      cache.set('2', 2);
      cache.set('3', 3);
      expect([...cache.entries()]).toEqual([['2', 2], ['3', 3]]);
    });
    it('`clear`', () => {
      const cache = new _restricted.default(2);
      cache.set('foo', 1);
      cache.set('bar', 2);
      expect(cache.has('foo')).toBeTrue();
      expect(cache.has('bar')).toBeTrue();
      expect(cache.clear()).toEqual(new Map([['foo', 1], ['bar', 2]]));
    });
    it('`clear` with a filter', () => {
      const cache = new _restricted.default();
      cache.set('foo', 1);
      cache.set('bar', 2);
      expect(cache.has('foo')).toBeTrue();
      expect(cache.has('bar')).toBeTrue();
      expect(cache.clear(el => el > 1)).toEqual(new Map([['bar', 2]]));
    });
    it("modifying cache' capacity", () => {
      const cache = new _restricted.default(1);
      cache.set('foo', 1);
      cache.setCapacity(2);
      cache.set('bar', 2);
      expect(cache.has('foo')).toBeTrue();
      expect(cache.has('bar')).toBeTrue();
      expect(cache.setCapacity(0)).toEqual(new Map([['foo', 1], ['bar', 2]]));
      expect(cache.has('foo')).toBeFalse();
      expect(cache.has('bar')).toBeFalse();
    });
  });