mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-01 00:08:24 +09:00
[Test] Add a test
This commit is contained in:
parent
9c7c7a956c
commit
93149de584
89
test/text.ts
89
test/text.ts
@ -19,54 +19,61 @@ describe('Text', () => {
|
|||||||
], tokens);
|
], tokens);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('bold', () => {
|
it('逆関数で正しく復元できる', () => {
|
||||||
const tokens = analyze('**Strawberry** Pasta');
|
const text = '@himawari お腹ペコい :cat: #yryr';
|
||||||
assert.deepEqual([
|
assert.equal(analyze(text).map(x => x.content).join(''), text);
|
||||||
{ type: 'bold', content: '**Strawberry**', bold: 'Strawberry' },
|
|
||||||
{ type: 'text', content: ' Pasta' }
|
|
||||||
], tokens);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('mention', () => {
|
describe('elements', () => {
|
||||||
const tokens = analyze('@himawari お腹ペコい');
|
it('bold', () => {
|
||||||
assert.deepEqual([
|
const tokens = analyze('**Strawberry** Pasta');
|
||||||
{ type: 'mention', content: '@himawari', username: 'himawari' },
|
assert.deepEqual([
|
||||||
{ type: 'text', content: ' お腹ペコい' }
|
{ type: 'bold', content: '**Strawberry**', bold: 'Strawberry' },
|
||||||
], tokens);
|
{ type: 'text', content: ' Pasta' }
|
||||||
});
|
], tokens);
|
||||||
|
});
|
||||||
|
|
||||||
it('hashtag', () => {
|
it('mention', () => {
|
||||||
const tokens = analyze('Strawberry Pasta #alice');
|
const tokens = analyze('@himawari お腹ペコい');
|
||||||
assert.deepEqual([
|
assert.deepEqual([
|
||||||
{ type: 'text', content: 'Strawberry Pasta ' },
|
{ type: 'mention', content: '@himawari', username: 'himawari' },
|
||||||
{ type: 'hashtag', content: '#alice', hashtag: 'alice' }
|
{ type: 'text', content: ' お腹ペコい' }
|
||||||
], tokens);
|
], tokens);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('link', () => {
|
it('hashtag', () => {
|
||||||
const tokens = analyze('https://himasaku.net');
|
const tokens = analyze('Strawberry Pasta #alice');
|
||||||
assert.deepEqual([
|
assert.deepEqual([
|
||||||
{ type: 'link', content: 'https://himasaku.net' }
|
{ type: 'text', content: 'Strawberry Pasta ' },
|
||||||
], tokens);
|
{ type: 'hashtag', content: '#alice', hashtag: 'alice' }
|
||||||
});
|
], tokens);
|
||||||
|
});
|
||||||
|
|
||||||
it('emoji', () => {
|
it('link', () => {
|
||||||
const tokens = analyze(':cat:');
|
const tokens = analyze('https://himasaku.net');
|
||||||
assert.deepEqual([
|
assert.deepEqual([
|
||||||
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
|
{ type: 'link', content: 'https://himasaku.net' }
|
||||||
], tokens);
|
], tokens);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('block code', () => {
|
it('emoji', () => {
|
||||||
const tokens = analyze('```\nvar x = "Strawberry Pasta";\n```');
|
const tokens = analyze(':cat:');
|
||||||
assert.equal(tokens[0].type, 'code');
|
assert.deepEqual([
|
||||||
assert.equal(tokens[0].content, '```\nvar x = "Strawberry Pasta";\n```');
|
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
|
||||||
});
|
], tokens);
|
||||||
|
});
|
||||||
|
|
||||||
it('inline code', () => {
|
it('block code', () => {
|
||||||
const tokens = analyze('`var x = "Strawberry Pasta";`');
|
const tokens = analyze('```\nvar x = "Strawberry Pasta";\n```');
|
||||||
assert.equal(tokens[0].type, 'inline-code');
|
assert.equal(tokens[0].type, 'code');
|
||||||
assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`');
|
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";`');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('syntax highlighting', () => {
|
describe('syntax highlighting', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user