Skip to content

Commit ae4a021

Browse files
committed
✅ 增加点测试代码
1 parent d9b7217 commit ae4a021

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package me.chanjar.weixin.mp.bean.menu;
2+
3+
import org.testng.annotations.Test;
4+
5+
import java.util.List;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
import static org.testng.Assert.*;
9+
10+
/**
11+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
12+
* @date 2019-08-05
13+
*/
14+
public class WxMpGetSelfMenuInfoResultTest {
15+
16+
@Test
17+
public void testFromJson() {
18+
String json = "{\"is_menu_open\":1,\"selfmenu_info\":{\"button\":[{\"name\":\"学院\",\"sub_button\":{\"list\":[{\"type\":\"miniprogram\",\"name\":\"成语答题王\",\"url\":\"http:\\/\\/host\",\"appid\":\"wxf4dc5b4e7b35dcd1\",\"pagepath\":\"pages\\/index\\/index\"},{\"type\":\"miniprogram\",\"name\":\"大师课程\",\"url\":\"https:\\/\\/host\\/course\\/tutorial\",\"appid\":\"wxfd6acd566482c6cb\",\"pagepath\":\"pages\\/tutorialDetail\\/tutorialDetail\"}]}},{\"type\":\"miniprogram\",\"name\":\"学科商城\",\"url\":\"https:\\/\\/host\\/-dAEuY\",\"appid\":\"wx720f9f1301595564\",\"pagepath\":\"pages\\/home\\/dashboard\\/index\"}]}}";
19+
final WxMpGetSelfMenuInfoResult selfMenuInfoResult = WxMpGetSelfMenuInfoResult.fromJson(json);
20+
assertThat(selfMenuInfoResult).isNotNull();
21+
assertThat(selfMenuInfoResult.getIsMenuOpen()).isEqualTo(1);
22+
assertThat(selfMenuInfoResult.getSelfMenuInfo()).isNotNull();
23+
final List<WxMpSelfMenuInfo.WxMpSelfMenuButton> buttons = selfMenuInfoResult.getSelfMenuInfo().getButtons();
24+
assertThat(buttons.size()).isEqualTo(2);
25+
assertThat(buttons.get(1).getAppId()).isEqualTo("wx720f9f1301595564");
26+
assertThat(buttons.get(1).getPagePath()).isEqualTo("pages/home/dashboard/index");
27+
}
28+
}

0 commit comments

Comments
 (0)