emoji counting, fix #141

This commit is contained in:
Nicolas Constant 2019-07-29 18:38:55 -04:00
parent ed43487091
commit 1c4438dbb9
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 9 additions and 1 deletions

View File

@ -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;

View File

@ -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;
} }

View File

@ -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"
], ],