{"size": 1372, "ext": "js", "max_stars_repo_path": "src/index.test.js", "max_stars_repo_name": "jojoee/thai-names", "max_stars_repo_stars_event_min_datetime": "2017-01-28T13:48:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T15:08:17.000Z", "max_issues_repo_path": "src/index.test.js", "max_issues_repo_name": "jojoee/thai-names", "max_issues_repo_issues_event_min_datetime": "2018-12-25T23:55:04.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-25T23:55:04.000Z", "max_forks_repo_path": "src/index.test.js", "max_forks_repo_name": "jojoee/thai-names", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 23.6551724138, "max_line_length": 80, "alphanum_fraction": 0.5422740525}
import {expect} from 'chai';
import thaiNames from './index';

describe('thai-names', function() {
  describe('all', function() {
    var allItems;

    before(function() {
      allItems = thaiNames.all();
    });

    it('should be an object', function() {
      expect(allItems).to.satisfy(function(items) {
        return items.every(function(item) {
          return (
            typeof item.name === 'string' &&
            typeof item.meaning.en === 'string' &&
            typeof item.meaning.th === 'string'
          );
        });
      });
    });

    it('should contain `Aileen`', function() {
      expect(allItems).to.include({
        "name": "Aileen",
        "meaning": {
          "en": "",
          "th": "อเมริกัน แปลว่า แสงสว่าง"
        }
      });
    });
  });

  describe('random', function() {
    var allItems;

    before(function() {
      allItems = thaiNames.all();
    });

    it('should return a random item from the thaiNames.all()', function() {
      var randomItem = thaiNames.random();

      expect(allItems).to.include(randomItem);
    });

    it('should return an array of random items if passed a number', function() {
      var randomItems = thaiNames.random(3);

      expect(randomItems).to.have.length(3);
      randomItems.forEach(function(item) {
        expect(allItems).to.include(item);
      });
    });
  });
});
