我正在测试一个提供 UIAlertController 的函数,但测试一直失败。这是函数的样子:
func presentBuyingErrorDialogue() {
let alert = UIAlertController(
title: "Warning",
message: "Error purchasing item, please retry this action. If that doesn't help, try restarting or reinstalling the app.",
preferredStyle: .alert
)
let okButton = UIAlertAction(title: "OK", style: .default)
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
由于此函数位于名为 ShopViewController 的类中,因此我假设测试此函数的正确方法是调用该函数shopViewController.presentBuyingErrorDiaologue()然后使用XCTAssertTrue(shopViewController.presentedViewController is UIAlertController). 但是,当我运行测试时,断言语句失败。测试 UIAlertController 是呈现视图的正确方法是什么?
我目前正在使用 rrule 插件开发 Fullcalendar v4
我有这个代码
var calendarEl = document.getElementById('calendardemo');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ['interaction', 'dayGrid', 'timeGrid', 'momentTimezone', 'rrule', 'list'],
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
editable: true,
events: [
{ // standard property
title: 'This is sample event',
start: '2019-12-29',
end: '2019-12-31'
},
{
title: 'event with rrule plugin',
rrule: {
freq: 'weekly',
interval: 5,
byweekday: [ 'mo', 'fr' ],
dtstart: '2019-12-29T10:30:00',
until: '2020-12-31'
}
}
]
});
calendar.render();
Run Code Online (Sandbox Code Playgroud)
请注意:
{ // …Run Code Online (Sandbox Code Playgroud)