1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/tests/unit/helpers/gh-count-down-characters-test.js
Kevin Ansfield 7afb88a0c2 Switch to eslint-plugin-ghost extending plugin:ghost/ember
no issue
- fix lint errors in lib/gh-koenig
- fix ghost:base eslint errors
- update ember plugin refs, remove ember-suave plugin refs
- remove old jshint refs
- add `lint:js` script
- switch to `eslint-plugin-ghost` extending `plugin:ghost/ember`
2018-01-12 12:17:56 +00:00

32 lines
1.2 KiB
JavaScript

import {countDownCharacters} from 'ghost-admin/helpers/gh-count-down-characters';
import {describe, it} from 'mocha';
import {expect} from 'chai';
describe('Unit: Helper: gh-count-down-characters', function () {
let validStyle = 'color: rgb(159, 187, 88);';
let errorStyle = 'color: rgb(226, 84, 64);';
it('counts chars', function () {
let result = countDownCharacters(['test', 200]);
expect(result.string)
.to.equal(`<span class="word-count" style="${validStyle}">4</span>`);
});
it('warns with too many chars', function () {
let result = countDownCharacters([Array(205 + 1).join('x'), 200]);
expect(result.string)
.to.equal(`<span class="word-count" style="${errorStyle}">205</span>`);
});
it('counts multibyte correctly', function () {
let result = countDownCharacters(['💩', 200]);
expect(result.string)
.to.equal(`<span class="word-count" style="${validStyle}">1</span>`);
// emoji + modifier is still two chars
result = countDownCharacters(['💃🏻', 200]);
expect(result.string)
.to.equal(`<span class="word-count" style="${validStyle}">2</span>`);
});
});