Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
test: add grid URL unit tests
周屹峰90f69c3f2dfd
diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rsindex ba221853bb..3cf5d6f99b 100644--- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs+++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/url_type_option/url_tests.rs@@ -14,6 +14,7 @@ mod tests {let field_type = FieldType::URL;let field_rev = FieldBuilder::from_field_type(&field_type).build();assert_url(&type_option, "123", "123", "", &field_type, &field_rev);+ assert_url(&type_option, "", "", "", &field_type, &field_rev);}/// The expected_str will equal to the input string, but the expected_url will not be empty@@ -42,6 +43,124 @@ mod tests {);}+ /// if there's a http url and some words following it in the input string.+ #[test]+ fn url_type_option_contains_url_with_string_after_test() {+ let type_option = URLTypeOption::default();+ let field_type = FieldType::URL;+ let field_rev = FieldBuilder::from_field_type(&field_type).build();+ assert_url(+ &type_option,+ "AppFlowy website - https://www.appflowy.io welcome!",+ "AppFlowy website - https://www.appflowy.io welcome!",+ "https://www.appflowy.io/",+ &field_type,+ &field_rev,+ );++ assert_url(+ &type_option,+ "AppFlowy website appflowy.io welcome!",+ "AppFlowy website appflowy.io welcome!",+ "https://appflowy.io",+ &field_type,+ &field_rev,+ );+ }++ /// if there's a http url and special words following it in the input string.+ #[test]+ fn url_type_option_contains_url_with_special_string_after_test() {+ let type_option = URLTypeOption::default();+ let field_type = FieldType::URL;+ let field_rev = FieldBuilder::from_field_type(&field_type).build();+ assert_url(+ &type_option,+ "AppFlowy website - https://www.appflowy.io!",+ "AppFlowy website - https://www.appflowy.io!",+ "https://www.appflowy.io/",+ &field_type,+ &field_rev,+ );++ assert_url(+ &type_option,+ "AppFlowy website appflowy.io!",+ "AppFlowy website appflowy.io!",+ "https://appflowy.io",+ &field_type,+ &field_rev,+ );+ }++ /// if there's a level4 url in the input string.+ #[test]+ fn level4_url_type_test() {+ let type_option = URLTypeOption::default();+ let field_type = FieldType::URL;+ let field_rev = FieldBuilder::from_field_type(&field_type).build();+ assert_url(+ &type_option,+ "test - https://tester.testgroup.appflowy.io",+ "test - https://tester.testgroup.appflowy.io",+ "https://tester.testgroup.appflowy.io/",+ &field_type,+ &field_rev,+ );++ assert_url(+ &type_option,+ "test tester.testgroup.appflowy.io",+ "test tester.testgroup.appflowy.io",+ "https://tester.testgroup.appflowy.io",+ &field_type,+ &field_rev,+ );+ }++ /// urls with different top level domains.+ #[test]+ fn different_top_level_domains_test() {+ let type_option = URLTypeOption::default();+ let field_type = FieldType::URL;+ let field_rev = FieldBuilder::from_field_type(&field_type).build();+ assert_url(+ &type_option,+ "appflowy - https://appflowy.com",+ "appflowy - https://appflowy.com",+ "https://appflowy.com/",+ &field_type,+ &field_rev,+ );++ assert_url(+ &type_option,+ "appflowy - https://appflowy.top",+ "appflowy - https://appflowy.top",+ "https://appflowy.top/",+ &field_type,+ &field_rev,+ );++ assert_url(+ &type_option,+ "appflowy - https://appflowy.net",+ "appflowy - https://appflowy.net",+ "https://appflowy.net/",+ &field_type,+ &field_rev,+ );++ assert_url(+ &type_option,+ "appflowy - https://appflowy.edu",+ "appflowy - https://appflowy.edu",+ "https://appflowy.edu/",+ &field_type,+ &field_rev,+ );+ }+fn assert_url(type_option: &URLTypeOption,input_str: &str,