-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
38 lines (32 loc) · 1.1 KB
/
index.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
const Parser = require('.');
describe('Emoji parser', () => {
it('should save path parameter', () => {
const path = '/images/';
const parser = new Parser(path);
expect(parser.path).toBe(path);
});
it('should parse emoji', () => {
const parser = new Parser('/images/');
const result = parser.parse('Text 🙂 text');
expect(result).toBe('Text <img draggable="false" class="emoji" src="/images/1f642.png"> text');
});
it('should not crash for null', () => {
const parser = new Parser('/images/');
const result = parser.parse(null);
expect(result).toBe(null);
});
it('should not crash for undefined', () => {
const parser = new Parser('/images/');
const result = parser.parse(undefined);
expect(result).toBe(undefined);
});
it('should not crash for empty string', () => {
const parser = new Parser('/images/');
const result = parser.parse('');
expect(result).toBe('');
});
it('should throw an error', () => {
const fn = () => new Parser();
expect(fn).toThrow('You should pass images path as the parameter to the constructor');
});
});