From 861b57b51db8a27bb5b54c32d0c84bbbcea075e6 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sun, 28 Mar 2021 21:23:22 +0900 Subject: [PATCH] add test --- test/main.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/main.ts b/test/main.ts index 4ec7b02..0f20825 100644 --- a/test/main.ts +++ b/test/main.ts @@ -1,5 +1,5 @@ import assert from 'assert'; -import { inspect, parse, parsePlain, toString } from '../built/index'; +import { extract, inspect, parse, parsePlain, toString } from '../built/index'; import { createNode } from '../built/util'; import { TEXT, CENTER, FN, UNI_EMOJI, MENTION, EMOJI_CODE, HASHTAG, N_URL, BOLD, SMALL, ITALIC, STRIKE, QUOTE, MATH_BLOCK, SEARCH, CODE_BLOCK @@ -487,3 +487,15 @@ describe('inspect', () => { assert.strictEqual(toString(result), 'hello [tada everynyan!]'); }); }); + +describe('extract API', () => { + it('basic', () => { + const nodes = parse('abc:hoge:[tada 123:hoge:]:piyo:'); + const expect = [ + EMOJI_CODE('hoge'), + EMOJI_CODE('hoge'), + EMOJI_CODE('piyo') + ]; + assert.deepStrictEqual(extract(nodes, 'emojiCode'), expect); + }); +});