diff --git a/test/main.ts b/test/main.ts index 4ec7b0238f21ea189f59a6b7fa8f92db6dbcff83..0f20825abf69b8a10df083ba1d759bb46fe2bdc0 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); + }); +});