// // Copyright Amazon.com Inc. or its affiliates. // All Rights Reserved. // // SPDX-License-Identifier: Apache-2.0 // import XCTest @testable import Amplify @testable import AWSPredictionsPlugin class InterpretBasicIntegrationTests: AWSPredictionsPluginTestBase { /// Test if we can make successful call to interpret /// /// - Given: Configured Amplify with prediction added /// - When: /// - I invoke interpret with text /// - Then: /// - Should return no empty result /// func testInterpretText() async throws { let inputText = """ Here is a text to be tested. This text contains emojis like πŸ™ƒπŸ˜† and like πŸš€. Also it contains entities like places in Seattle and on November 19. Text is long enough to have happy emotions. """ let result = try await Amplify.Predictions.interpret(text: inputText, options: .init(defaultNetworkPolicy: .online)) XCTAssertNotNil(result, "Result should contain value") } /// Test if we can make successful calls to interpret when different input texts containing one or more emoji ZWJ (zero width joiner)/modifier /// sequences. /// /// - Given: Configured Amplify with prediction added /// - When: /// - I invoke interpret with text /// - Then: /// - Should return no empty result /// func testInterpretTextWithEmojisWithMultipleUnicodeScalars() async throws { let inputTexts = [ // 1 """ πŸ‘‡πŸΎ is a modifier sequence combining πŸ‘‡ Backhand Index Pointing Down and 🏾 Medium-Dark Skin tone. """, // 2 """ β€œHere's to the crazy ones. The misfits. The rebels. The troublemakers πŸ΄β€β˜ οΈβ€œ. A pirate flag is ZWJ sequence combining 🏴, Zero Width Joiner and ☠️. """, // 3 """ πŸ‘©β€πŸ‘©β€πŸ‘§β€πŸ‘§ family emojii is a ZWJ sequence combining: πŸ‘© Woman, Zero Width Joiner, πŸ‘© Woman, Zero Width Joiner, πŸ‘§ Girl, Zero Width Joiner and a πŸ‘§ Girl. """ ] for text in inputTexts { let result = try await Amplify.Predictions.interpret(text: text, options: .init(defaultNetworkPolicy: .online)) XCTAssertNotNil(result, "Result should contain value") } } /// Test if we can make successful call to interpret /// /// - Given: Configured Amplify with prediction added /// - When: /// - I invoke interpret with text on offline mode /// - Then: /// - Should return no empty result /// func testInterpretTextOffline() async throws { let options = Predictions.Interpret.Options( defaultNetworkPolicy: .online, pluginOptions: nil ) let result = try await Amplify.Predictions.interpret( text: "Hello there how are you?", options: options ) XCTAssertNotNil(result, "Result should contain value") } }