Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sfm-js
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
sfm-js
Commits
72d85e79
Commit
72d85e79
authored
3 years ago
by
marihachi
Browse files
Options
Downloads
Patches
Plain Diff
update parser test
parent
b12feb09
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/parser.ts
+32
-21
32 additions, 21 deletions
test/parser.ts
with
32 additions
and
21 deletions
test/parser.ts
+
32
−
21
View file @
72d85e79
...
@@ -7,7 +7,7 @@ import {
...
@@ -7,7 +7,7 @@ import {
describe
(
'
parser
'
,
()
=>
{
describe
(
'
parser
'
,
()
=>
{
describe
(
'
text
'
,
()
=>
{
describe
(
'
text
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
it
(
'
普通のテキストを入力すると1つのテキストノードが返される
'
,
()
=>
{
const
input
=
'
abc
'
;
const
input
=
'
abc
'
;
const
output
=
[
TEXT
(
'
abc
'
)];
const
output
=
[
TEXT
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
...
@@ -15,7 +15,7 @@ describe('parser', () => {
...
@@ -15,7 +15,7 @@ describe('parser', () => {
});
});
describe
(
'
quote
'
,
()
=>
{
describe
(
'
quote
'
,
()
=>
{
it
(
'
single
'
,
()
=>
{
it
(
'
1行の引用ブロックを使用できる
'
,
()
=>
{
const
input
=
'
> abc
'
;
const
input
=
'
> abc
'
;
const
output
=
[
const
output
=
[
QUOTE
([
QUOTE
([
...
@@ -24,7 +24,7 @@ describe('parser', () => {
...
@@ -24,7 +24,7 @@ describe('parser', () => {
];
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
multiple
'
,
()
=>
{
it
(
'
複数行の引用ブロックを使用できる
'
,
()
=>
{
const
input
=
`
const
input
=
`
> abc
> abc
> 123
> 123
...
@@ -36,8 +36,7 @@ describe('parser', () => {
...
@@ -36,8 +36,7 @@ describe('parser', () => {
];
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
引用ブロックはブロックをネストできる
'
,
()
=>
{
it
(
'
with block (center)
'
,
()
=>
{
const
input
=
`
const
input
=
`
> <center>
> <center>
> a
> a
...
@@ -52,8 +51,7 @@ describe('parser', () => {
...
@@ -52,8 +51,7 @@ describe('parser', () => {
];
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
引用ブロックはインライン構文を含んだブロックをネストできる
'
,
()
=>
{
it
(
'
with block (center, mention)
'
,
()
=>
{
const
input
=
`
const
input
=
`
> <center>
> <center>
> I'm @ai, An bot of misskey!
> I'm @ai, An bot of misskey!
...
@@ -73,7 +71,7 @@ describe('parser', () => {
...
@@ -73,7 +71,7 @@ describe('parser', () => {
});
});
describe
(
'
search
'
,
()
=>
{
describe
(
'
search
'
,
()
=>
{
describe
(
'
basic
'
,
()
=>
{
describe
(
'
検索構文を使用できる
'
,
()
=>
{
it
(
'
Search
'
,
()
=>
{
it
(
'
Search
'
,
()
=>
{
const
input
=
'
MFM 書き方 123 Search
'
;
const
input
=
'
MFM 書き方 123 Search
'
;
const
output
=
[
const
output
=
[
...
@@ -135,7 +133,7 @@ describe('parser', () => {
...
@@ -135,7 +133,7 @@ describe('parser', () => {
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
});
});
it
(
'
with text
'
,
()
=>
{
it
(
'
ブロックの前後にあるテキストが正しく解釈される
'
,
()
=>
{
const
input
=
'
abc
\n
hoge piyo bebeyo 検索
\n
123
'
;
const
input
=
'
abc
\n
hoge piyo bebeyo 検索
\n
123
'
;
const
output
=
[
const
output
=
[
TEXT
(
'
abc
'
),
TEXT
(
'
abc
'
),
...
@@ -147,22 +145,22 @@ describe('parser', () => {
...
@@ -147,22 +145,22 @@ describe('parser', () => {
});
});
describe
(
'
code block
'
,
()
=>
{
describe
(
'
code block
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
it
(
'
コードブロックを使用できる
'
,
()
=>
{
const
input
=
'
```
\n
abc
\n
```
'
;
const
input
=
'
```
\n
abc
\n
```
'
;
const
output
=
[
CODE_BLOCK
(
'
abc
'
,
null
)];
const
output
=
[
CODE_BLOCK
(
'
abc
'
,
null
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
multi line
'
,
()
=>
{
it
(
'
コードブロックには複数行のコードを入力できる
'
,
()
=>
{
const
input
=
'
```
\n
a
\n
b
\n
c
\n
```
'
;
const
input
=
'
```
\n
a
\n
b
\n
c
\n
```
'
;
const
output
=
[
CODE_BLOCK
(
'
a
\n
b
\n
c
'
,
null
)];
const
output
=
[
CODE_BLOCK
(
'
a
\n
b
\n
c
'
,
null
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
basic (lang)
'
,
()
=>
{
it
(
'
コードブロックは言語を指定できる
'
,
()
=>
{
const
input
=
'
```js
\n
const a = 1;
\n
```
'
;
const
input
=
'
```js
\n
const a = 1;
\n
```
'
;
const
output
=
[
CODE_BLOCK
(
'
const a = 1;
'
,
'
js
'
)];
const
output
=
[
CODE_BLOCK
(
'
const a = 1;
'
,
'
js
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
with text
'
,
()
=>
{
it
(
'
ブロックの前後にあるテキストが正しく解釈される
'
,
()
=>
{
const
input
=
'
abc
\n
```
\n
const abc = 1;
\n
```
\n
123
'
;
const
input
=
'
abc
\n
```
\n
const abc = 1;
\n
```
\n
123
'
;
const
output
=
[
const
output
=
[
TEXT
(
'
abc
'
),
TEXT
(
'
abc
'
),
...
@@ -174,20 +172,33 @@ describe('parser', () => {
...
@@ -174,20 +172,33 @@ describe('parser', () => {
});
});
describe
(
'
mathBlock
'
,
()
=>
{
describe
(
'
mathBlock
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
it
(
'
1行の数式ブロックを使用できる
'
,
()
=>
{
const
input
=
'
123
\n\\
[math1
\\
]
\n
abc
\n\\
[math2
\\
]
'
;
const
input
=
'
\\
[math1
\\
]
'
;
const
output
=
[
MATH_BLOCK
(
'
math1
'
)
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
it
(
'
ブロックの前後にあるテキストが正しく解釈される
'
,
()
=>
{
const
input
=
'
abc
\n\\
[math1
\\
]
\n
123
'
;
const
output
=
[
const
output
=
[
TEXT
(
'
123
'
),
MATH_BLOCK
(
'
math1
'
),
TEXT
(
'
abc
'
),
TEXT
(
'
abc
'
),
MATH_BLOCK
(
'
math2
'
)
MATH_BLOCK
(
'
math1
'
),
TEXT
(
'
123
'
)
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
it
(
'
行末以外に閉じタグがある場合はマッチしない
'
,
()
=>
{
const
input
=
'
\\
[aaa
\\
]after
'
;
const
output
=
[
TEXT
(
'
\\
[aaa
\\
]after
'
)
];
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
case of no matched
'
,
()
=>
{
it
(
'
行頭以外に開始タグがある場合はマッチしない
'
,
()
=>
{
const
input
=
'
\\
[aaa
\\
]
\\
[bbb
\\
]
'
;
const
input
=
'
before
\\
[aaa
\\
]
'
;
const
output
=
[
const
output
=
[
TEXT
(
'
\\
[aaa
\\
]
\\
[bbb
\\
]
'
)
TEXT
(
'
before
\\
[aaa
\\
]
'
)
];
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment