summaryrefslogtreecommitdiff
path: root/test/text.ts
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2017-02-28 02:48:37 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2017-02-28 02:48:37 +0900
commit6f497a3bd5fedee272071fc4c9476b792aa91db4 (patch)
treecc0d15ca7562e5c1692fcc321cb387c21ec1729a /test/text.ts
parentMerge branch 'mocha-ts' (diff)
downloadmisskey-6f497a3bd5fedee272071fc4c9476b792aa91db4.tar.gz
misskey-6f497a3bd5fedee272071fc4c9476b792aa91db4.tar.bz2
misskey-6f497a3bd5fedee272071fc4c9476b792aa91db4.zip
Use TypeScript for tests
Diffstat (limited to 'test/text.ts')
-rw-r--r--test/text.ts68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/text.ts b/test/text.ts
new file mode 100644
index 0000000000..78945c65a3
--- /dev/null
+++ b/test/text.ts
@@ -0,0 +1,68 @@
+/**
+ * Text Tests!
+ */
+
+const assert = require('assert');
+
+const analyze = require('../src/common/text');
+//const complie = require('../src/web/app/common/scripts/text-compiler');
+
+describe('Text', () => {
+ it('is correctly analyzed', () => {
+ const tokens = analyze('@himawari お腹ペコい #yryr');
+ assert.deepEqual([
+ { type: 'mention', content: '@himawari', username: 'himawari' },
+ { type: 'text', content: ' お腹ペコい ' },
+ { type: 'hashtag', content: '#yryr', hashtag: 'yryr' }
+ ], tokens);
+ });
+
+ it('bold', () => {
+ const tokens = analyze('**Strawberry** Pasta');
+ assert.deepEqual([
+ { type: 'bold', content: '**Strawberry**', bold: 'Strawberry' },
+ { type: 'text', content: ' Pasta' }
+ ], tokens);
+ });
+
+ it('mention', () => {
+ const tokens = analyze('@himawari お腹ペコい');
+ assert.deepEqual([
+ { type: 'mention', content: '@himawari', username: 'himawari' },
+ { type: 'text', content: ' お腹ペコい' }
+ ], tokens);
+ });
+
+ it('hashtag', () => {
+ const tokens = analyze('Strawberry Pasta #alice');
+ assert.deepEqual([
+ { type: 'text', content: 'Strawberry Pasta ' },
+ { type: 'hashtag', content: '#alice', hashtag: 'alice' }
+ ], tokens);
+ });
+
+ it('link', () => {
+ const tokens = analyze('https://himasaku.net');
+ assert.deepEqual([
+ { type: 'link', content: 'https://himasaku.net' }
+ ], tokens);
+ });
+
+ it('block code', () => {
+ const tokens = analyze('```\nvar x = "Strawberry Pasta";\n```');
+ assert.equal(tokens[0].type, 'code');
+ assert.equal(tokens[0].content, '```\nvar x = "Strawberry Pasta";\n```');
+ });
+
+ it('inline code', () => {
+ const tokens = analyze('`var x = "Strawberry Pasta";`');
+ assert.equal(tokens[0].type, 'inline-code');
+ assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`');
+ });
+
+/*
+ it('正しくコンパイルされる', () => {
+ assert.equal(-1, [1,2,3].indexOf(4));
+ });
+*/
+});