Skip to content

Commit f218e1c

Browse files
author
Youzhi Yu
committed
added tests
1 parent bd65625 commit f218e1c

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

DESCRIPTION

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
Package: tidyEmoji
22
Type: Package
3-
Title: Detects Emoji on Text
3+
Title: Discovers Emoji from Text
44
Version: 0.1.0
55
Author: Youzhi Yu
66
Maintainer: Youzhi Yu <[email protected]>
77
Description: Unicodes are not friendly to work with, and not all Unicodes are
8-
Emoji per se, making obtaining Emoji statistics a not-so-easy task. This
9-
tool can help your experience of working with Emoji as smooth as possible.
8+
Emoji per se, making obtaining Emoji statistics a difficult task. This
9+
tool can help your experience of working with Emoji as smooth as possible,
10+
as it has the tidyverse style.
1011
License: GPL (>= 3)
1112
Encoding: UTF-8
1213
LazyData: true
1314
RoxygenNote: 7.1.2
15+
Depends:
16+
R (>= 3.5.0)
1417
Imports:
1518
dplyr,
1619
emoji,
@@ -19,3 +22,6 @@ Imports:
1922
tibble,
2023
tidyr,
2124
utils
25+
Suggests:
26+
testthat (>= 3.0.0)
27+
Config/testthat/edition: 3

tests/testthat.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(testthat)
2+
library(tidyEmoji)
3+
4+
test_check("tidyEmoji")

tests/testthat/test-dimensions.R

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
library(dplyr)
2+
3+
df <- data.frame(tweets = c("I love tidyverse \U0001f600\U0001f603\U0001f603",
4+
"R is my language! \U0001f601\U0001f606\U0001f605",
5+
"This Tweet does not have Emoji!",
6+
"Wearing a mask\U0001f637\U0001f637\U0001f637.",
7+
"Emoji does not appear in all Tweets"))
8+
9+
10+
test_that("emoji_summary dimension", {
11+
12+
expect_equal(
13+
df %>%
14+
emoji_summary(tweets) %>%
15+
pull(emoji_tweets),
16+
3
17+
)
18+
19+
expect_equal(
20+
df %>%
21+
emoji_summary(tweets) %>%
22+
pull(total_tweets),
23+
5
24+
)
25+
})
26+
27+
28+
test_that("emoji_tweets dimension", {
29+
expect_equal(
30+
df %>%
31+
emoji_tweets(tweets) %>%
32+
dim() %>%
33+
.[1],
34+
3
35+
)
36+
})
37+
38+
39+
40+
test_that("top_n_emojis emoji names", {
41+
expect_identical(
42+
df %>%
43+
top_n_emojis(tweets, n = 1) %>%
44+
pull(emoji_name),
45+
"face_with_medical_mask"
46+
)
47+
})
48+
49+

0 commit comments

Comments
 (0)