{"size": 1615, "ext": "js", "max_stars_repo_path": "test/handlers.js", "max_stars_repo_name": "tomhooijenga/access", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/handlers.js", "max_issues_repo_name": "tomhooijenga/access", "max_issues_repo_issues_event_min_datetime": "2020-10-03T10:10:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-27T14:20:38.000Z", "max_forks_repo_path": "test/handlers.js", "max_forks_repo_name": "tomhooijenga/access", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 22.4305555556, "max_line_length": 69, "alphanum_fraction": 0.5188854489}
const should = require('should');
const { access } = require('../dist');
const types = require('./types');

types.forEach(({
  setup,
  name,
  key1,
  key2,
  factory,
}) => {
  describe(name, () => {
    let obj;

    beforeEach(() => {
      if (setup) {
        setup();
      }

      obj = factory();
    });

    it('get', () => {
      access.get(obj, key1).should.equal('value');
      should(access.get(obj, 'does_not_exist')).be.undefined();
    });

    it('set', () => {
      access.set(obj, key2, 'new_value');
      access.get(obj, key2).should.equal('new_value');
    });

    it('has', () => {
      access.has(obj, key1).should.be.true();
      access.has(obj, 'does_not_exist').should.be.false();
    });

    it('delete', () => {
      access.delete(obj, key1).should.be.true();
      access.delete(obj, 'does_not_exist').should.be.false();
      access.has(obj, key1).should.be.false();
    });

    it('clear', () => {
      should(access.clear(obj)).be.undefined();

      access.size(obj).should.equal(0);
    });

    it('size', () => {
      access.size(obj).should.equal(1);
      access.set(obj, key2, 'new_value');
      access.size(obj).should.equal(2);
    });

    it('keys', () => {
      access.keys(obj).should.be.iterator();
      [...access.keys(obj)].should.eql([key1]);
    });

    it('values', () => {
      access.values(obj).should.be.iterator();
      [...access.values(obj)].should.eql(['value']);
    });

    it('entries', () => {
      access.entries(obj).should.be.iterator();
      [...access.entries(obj)].should.containDeep([[key1, 'value']]);
    });
  });
});
