emoji counting, fix #141
This commit is contained in:
parent
ed43487091
commit
1c4438dbb9
|
@ -50,6 +50,13 @@ describe('CreateStatusComponent', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not count emoji as multiple chars', () => {
|
||||||
|
const status = '😃 😍 👌 👇 😱 😶 status with 😱 😶 emojis 😏 👍 ';
|
||||||
|
(<any>component).maxCharLength = 500;
|
||||||
|
(<any>component).countStatusChar(status);
|
||||||
|
expect((<any>component).charCountLeft).toBe(461);
|
||||||
|
});
|
||||||
|
|
||||||
it('should not parse small status', () => {
|
it('should not parse small status', () => {
|
||||||
const status = 'this is a cool status';
|
const status = 'this is a cool status';
|
||||||
(<any>component).maxCharLength = 500;
|
(<any>component).maxCharLength = 500;
|
||||||
|
|
|
@ -356,7 +356,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
const currentStatus = parseStatus[parseStatus.length - 1];
|
const currentStatus = parseStatus[parseStatus.length - 1];
|
||||||
const statusExtraChars = this.getMentionExtraChars(status);
|
const statusExtraChars = this.getMentionExtraChars(status);
|
||||||
|
|
||||||
const statusLength = currentStatus.length - statusExtraChars;
|
const statusLength = [...currentStatus].length - statusExtraChars;
|
||||||
this.charCountLeft = this.maxCharLength - statusLength - this.getCwLength();
|
this.charCountLeft = this.maxCharLength - statusLength - this.getCwLength();
|
||||||
this.postCounts = parseStatus.length;
|
this.postCounts = parseStatus.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
|
"downlevelIteration": true,
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue