From 1f5db07f54a83b5cc920646ef65a1d36b131c8e4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 30 Dec 2016 13:28:56 +0900 Subject: [PATCH] Add test --- package.json | 3 ++- test/text.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/text.js diff --git a/package.json b/package.json index ab8cf2a20..112d1dbda 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "clean": "gulp clean", "cleanall": "gulp cleanall", "lint": "gulp lint", - "test": "gulp test" + "test": "mocha" }, "dependencies": { "@types/bcrypt": "1.0.0", @@ -96,6 +96,7 @@ "js-yaml": "3.7.0", "livescript": "1.5.0", "mime-types": "2.1.13", + "mocha": "3.2.0", "mongodb": "2.2.16", "ms": "0.7.2", "multer": "1.2.1", diff --git a/test/text.js b/test/text.js new file mode 100644 index 000000000..842b90041 --- /dev/null +++ b/test/text.js @@ -0,0 +1,21 @@ +const assert = require('assert'); + +const analyze = require('../src/common/text'); +//const complie = require('../src/web/app/common/scripts/text-compiler'); + +describe('Text', () => { + it('正しく解析される', () => { + const tokens = analyze('@himawari お腹ペコい #yryr'); + assert.deepEqual([ + { type: 'mention', content: '@himawari', username: 'himawari' }, + { type: 'text', content: ' お腹ペコい ' }, + { type: 'hashtag', content: '#yryr', hashtag: 'yryr' } + ], tokens); + }); + +/* + it('正しくコンパイルされる', () => { + assert.equal(-1, [1,2,3].indexOf(4)); + }); +*/ +});