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
97a362cf
Commit
97a362cf
authored
3 years ago
by
marihachi
Browse files
Options
Downloads
Patches
Plain Diff
update test
parent
b15e4d3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/inline.ts
+0
-49
0 additions, 49 deletions
test/inline.ts
test/main.ts
+161
-0
161 additions, 0 deletions
test/main.ts
test/node.ts
+9
-6
9 additions, 6 deletions
test/node.ts
with
170 additions
and
55 deletions
test/inline.ts
deleted
100644 → 0
+
0
−
49
View file @
b15e4d3c
import
assert
from
'
assert
'
;
import
{
parse
,
parsePlain
}
from
'
../built/index
'
;
import
{
createNode
}
from
'
../built/mfm-node
'
;
import
{
TEXT
,
EMOJI
,
UNI_EMOJI
,
HASHTAG
,
N_URL
}
from
'
./node
'
;
describe
(
'
text
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
abc
'
;
const
output
=
[
TEXT
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
custom emoji
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
:abc:
'
;
const
output
=
[
EMOJI
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
unicode emoji
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
今起きた😇
'
;
const
output
=
[
TEXT
(
'
今起きた
'
),
UNI_EMOJI
(
'
😇
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
hashtag
'
,
()
=>
{
it
(
'
and unicode emoji
'
,
()
=>
{
const
input
=
'
#️⃣abc123#abc
'
;
const
output
=
[
UNI_EMOJI
(
'
#️⃣
'
),
TEXT
(
'
abc123
'
),
HASHTAG
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
url
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
official instance: https://misskey.io/@ai.
'
;
const
output
=
[
TEXT
(
'
official instance:
'
),
N_URL
(
'
https://misskey.io/@ai
'
),
TEXT
(
'
.
'
)
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
This diff is collapsed.
Click to expand it.
test/
block
.ts
→
test/
main
.ts
+
161
−
0
View file @
97a362cf
import
assert
from
'
assert
'
;
import
{
parse
,
parsePlain
}
from
'
../built/index
'
;
import
{
createNode
}
from
'
../built/
mfm-node
'
;
import
{
createNode
}
from
'
../built/
util
'
;
import
{
TEXT
,
EMOJI
TEXT
,
CENTER
,
FN
,
UNI_EMOJI
,
MENTION
,
CUSTOM_EMOJI
,
HASHTAG
,
N_URL
}
from
'
./node
'
;
describe
(
'
text
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
abc
'
;
const
output
=
[
TEXT
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
custom emoji
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
:abc:
'
;
const
output
=
[
CUSTOM_EMOJI
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
unicode emoji
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
今起きた😇
'
;
const
output
=
[
TEXT
(
'
今起きた
'
),
UNI_EMOJI
(
'
😇
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
hashtag
'
,
()
=>
{
it
(
'
and unicode emoji
'
,
()
=>
{
const
input
=
'
#️⃣abc123#abc
'
;
const
output
=
[
UNI_EMOJI
(
'
#️⃣
'
),
TEXT
(
'
abc123
'
),
HASHTAG
(
'
abc
'
)];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
url
'
,
()
=>
{
it
(
'
basic
'
,
()
=>
{
const
input
=
'
official instance: https://misskey.io/@ai.
'
;
const
output
=
[
TEXT
(
'
official instance:
'
),
N_URL
(
'
https://misskey.io/@ai
'
),
TEXT
(
'
.
'
)
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
describe
(
'
search
'
,
()
=>
{
describe
(
'
basic
'
,
()
=>
{
it
(
'
Search
'
,
()
=>
{
...
...
@@ -69,3 +112,50 @@ describe('search', () => {
});
});
});
describe
(
'
center
'
,
()
=>
{
it
(
'
single text
'
,
()
=>
{
const
input
=
'
<center>abc</center>
'
;
const
output
=
[
CENTER
([
TEXT
(
'
abc
'
)
])
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
it
(
'
multiple text
'
,
()
=>
{
const
input
=
'
<center>
\n
abc
\n
123
\n\n
piyo
\n
</center>
'
;
const
output
=
[
CENTER
([
TEXT
(
'
\n
abc
\n
123
\n\n
piyo
\n
'
)
])
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
});
it
(
'
composite
'
,
()
=>
{
const
input
=
`<center>
Hello [tada everynyan! 🎉]
I'm @ai, A bot of misskey!
https://github.com/syuilo/ai
</center>`
;
const
output
=
[
CENTER
([
TEXT
(
'
\n
Hello
'
),
FN
(
'
tada
'
,
{
},
[
TEXT
(
'
everynyan!
'
),
UNI_EMOJI
(
'
🎉
'
)
]),
TEXT
(
'
\n\n
I
\'
m
'
),
MENTION
(
'
ai
'
,
null
,
'
@ai
'
),
TEXT
(
'
, A bot of misskey!
\n\n
'
),
N_URL
(
'
https://github.com/syuilo/ai
'
),
TEXT
(
'
\n
'
)
])
];
assert
.
deepStrictEqual
(
parse
(
input
),
output
);
});
This diff is collapsed.
Click to expand it.
test/node.ts
+
9
−
6
View file @
97a362cf
import
{
createNode
}
from
'
../built
/mfm-node
'
;
import
{
MfmCenter
,
MfmEmoji
,
MfmFn
,
MfmHashtag
,
MfmInline
,
MfmMention
,
MfmText
,
MfmUrl
}
from
'
../built
'
;
export
const
TEXT
=
(
value
:
string
)
=>
createNode
(
'
text
'
,
{
text
:
value
});
export
const
EMOJI
=
(
name
:
string
)
=>
createNode
(
'
emoji
'
,
{
name
:
name
});
export
const
UNI_EMOJI
=
(
value
:
string
)
=>
createNode
(
'
emoji
'
,
{
emoji
:
value
});
export
const
HASHTAG
=
(
value
:
string
)
=>
createNode
(
'
hashtag
'
,
{
hashtag
:
value
});
export
const
N_URL
=
(
value
:
string
)
=>
createNode
(
'
url
'
,
{
url
:
value
});
export
const
TEXT
=
(
value
:
string
):
MfmText
=>
{
return
{
type
:
'
text
'
,
props
:
{
text
:
value
},
children
:
[]
};
};
export
const
CUSTOM_EMOJI
=
(
name
:
string
):
MfmEmoji
=>
{
return
{
type
:
'
emoji
'
,
props
:
{
name
:
name
},
children
:
[]
};
};
export
const
UNI_EMOJI
=
(
value
:
string
):
MfmEmoji
=>
{
return
{
type
:
'
emoji
'
,
props
:
{
emoji
:
value
},
children
:
[]
};
};
export
const
HASHTAG
=
(
value
:
string
):
MfmHashtag
=>
{
return
{
type
:
'
hashtag
'
,
props
:
{
hashtag
:
value
},
children
:
[]
};
};
export
const
N_URL
=
(
value
:
string
):
MfmUrl
=>
{
return
{
type
:
'
url
'
,
props
:
{
url
:
value
},
children
:
[]
};
};
export
const
CENTER
=
(
children
:
MfmInline
[]):
MfmCenter
=>
{
return
{
type
:
'
center
'
,
props
:
{
},
children
};
};
export
const
FN
=
(
name
:
string
,
args
:
MfmFn
[
'
props
'
][
'
args
'
],
children
:
MfmFn
[
'
children
'
]):
MfmFn
=>
{
return
{
type
:
'
fn
'
,
props
:
{
name
,
args
},
children
};
};
export
const
MENTION
=
(
username
:
string
,
host
:
string
|
null
,
acct
:
string
):
MfmMention
=>
{
return
{
type
:
'
mention
'
,
props
:
{
username
,
host
,
acct
},
children
:
[]
};
};
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