<commit_before>import { load, all, exist, getUrl, parse } from './gh-emoji';
import tapeTest from 'tape';

const before = () => {};

const test = (title, cb) => {
  tapeTest(title, (...args) => {
    before();
    cb(...args);
  });
};

test('all() before load()', assert => {
  assert.equal(all(), null, 'must return null');
  assert.end();
});

test('load', assert => {
  load().then((emojis) => {
    assert.equal(typeof emojis, 'object', 'must resolve Object with emojis');
    assert.end();
  });
});

test('all() after load()', assert => {
  assert.equal(typeof all(), 'object', 'must return Object with emojis');
  assert.end();
});

test('exist', assert => {
  assert.ok(exist('8ball'), '8ball emoji exists');
  assert.ok(exist('aries'), 'aries emoji exists');
  assert.ok(!exist('fakeEmoji'), 'fakeEmoji emoji does not exists');
  assert.end();
});

test('getUrl', assert => {
  assert.ok(getUrl('angel').startsWith(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f47c.png'),
    'angel emoji must return url'
  );
  assert.ok(getUrl('baby').startsWith(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f476.png'),
    'baby emoji must return url'
  );
  assert.ok(!getUrl('fakeEmoji'), 'fakeEmoji emoji must not return url');
  assert.end();
});

test('parse', assert => {
  assert.ok(parse(':bicyclist:') === '<img src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f6b4.png?v6" class="gh-emoji gh-emoji-bicyclist" alt="bicyclist" />',
    'string is properly parsed'
  );
  assert.ok(parse('foo :barber: bar :bell:').includes(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f514.png'),
    'parsed string includes url of emoji'
  );
  assert.ok(parse('foo :barber: bar :bell:').includes(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f488.png'),
    'parsed string includes url of emoji'
  );
  assert.end();
});<commit_msg>Add test for no emoji present<commit_after>import { load, all, exist, getUrl, parse } from './gh-emoji';
import tapeTest from 'tape';

const before = () => {};

const test = (title, cb) => {
  tapeTest(title, (...args) => {
    before();
    cb(...args);
  });
};

test('all() before load()', assert => {
  assert.equal(all(), null, 'must return null');
  assert.end();
});

test('load', assert => {
  load().then((emojis) => {
    assert.equal(typeof emojis, 'object', 'must resolve Object with emojis');
    assert.end();
  });
});

test('all() after load()', assert => {
  assert.equal(typeof all(), 'object', 'must return Object with emojis');
  assert.end();
});

test('exist', assert => {
  assert.ok(exist('8ball'), '8ball emoji exists');
  assert.ok(exist('aries'), 'aries emoji exists');
  assert.ok(!exist('fakeEmoji'), 'fakeEmoji emoji does not exists');
  assert.end();
});

test('getUrl', assert => {
  assert.ok(getUrl('angel').startsWith(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f47c.png'),
    'angel emoji must return url'
  );
  assert.ok(getUrl('baby').startsWith(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f476.png'),
    'baby emoji must return url'
  );
  assert.ok(!getUrl('fakeEmoji'), 'fakeEmoji emoji must not return url');
  assert.end();
});

test('parse', assert => {
  assert.ok(parse('No emoji present') === 'No emoji present',
    'return the same string if no emoji is present'
  );
  assert.ok(parse(':bicyclist:') === '<img src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f6b4.png?v6" class="gh-emoji gh-emoji-bicyclist" alt="bicyclist" />',
    'string is properly parsed'
  );
  assert.ok(parse('foo :barber: bar :bell:').includes(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f514.png'),
    'parsed string includes url of emoji'
  );
  assert.ok(parse('foo :barber: bar :bell:').includes(
    'https://assets-cdn.github.com/images/icons/emoji/unicode/1f488.png'),
    'parsed string includes url of emoji'
  );
  assert.end();
});
{'fraction_non_alphanumeric': 0.20874399797826637, 'fraction_numerical': 0.01061410159211524, 'mean_word_length': 4.074358974358974, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '577143', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1431, 'n_words': 286}