UNPKG

node-elizabeth

Version:
54 lines (39 loc) 1.58 kB
'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _providers = require('../providers.js'); var _util = require('./../util'); var data = (0, _util.pull)('text.json', 'en'); var text = new _providers.Text(); describe('Test text provider', function () { it('should return array', function () { expect(text.alphabet()).toBeInstanceOf(Array); }); it('should return string', function () { expect(_typeof(text.level())).toBe('string'); }); it('should be string and length >= 4', function () { expect(_typeof(text.text())).toBe('string'); expect(text.text({ quantity: 4 })).toMatch(/^[^,]{4,}/); }); it('should be length == 6', function () { expect(text.words({ quantity: 6 })).toHaveLength(6); }); it('should be in array', function () { expect(data.words.bad).toContain(text.swearWord()); }); it('should be in array', function () { expect(data.words.normal).toContain(text.word()); }); it('should be in array', function () { expect(data.quotes).toContain(text.quote()); }); it('should be in array', function () { expect(data.color).toContain(text.color()); }); it('should be format #23A2AA', function () { expect(text.hexColor()).toMatch(/^#[0-9A-Z]{6}/); }); it('should be in array', function () { expect(data.answers).toContain(text.answer()); }); });