@cap-kit/test-plugin 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{TestPlugin.podspec → CapKitTest.podspec} +1 -1
- package/Package.swift +8 -5
- package/android/src/main/java/io/capkit/test/{Test.kt → TestImpl.kt} +5 -5
- package/android/src/main/java/io/capkit/test/TestPlugin.kt +4 -4
- package/android/src/main/java/io/capkit/test/utils/{Logger.kt → TestLogger.kt} +1 -1
- package/ios/Sources/TestPlugin/{Test.swift → TestImpl.swift} +1 -1
- package/ios/Sources/TestPlugin/TestPlugin.swift +1 -1
- package/ios/Tests/TestPluginTests/TestPluginTests.swift +7 -1
- package/package.json +3 -3
- /package/ios/Sources/TestPlugin/Utils/{Logging.swift → TestLogger.swift} +0 -0
package/Package.swift
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import PackageDescription
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
|
-
name: "
|
|
5
|
+
name: "CapKitTest",
|
|
6
6
|
platforms: [.iOS(.v15)],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
|
-
name: "
|
|
10
|
-
targets: ["TestPlugin"]
|
|
9
|
+
name: "CapKitTest",
|
|
10
|
+
targets: ["TestPlugin"]
|
|
11
|
+
)
|
|
11
12
|
],
|
|
12
13
|
dependencies: [
|
|
13
14
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
@@ -17,8 +18,10 @@ let package = Package(
|
|
|
17
18
|
name: "TestPlugin",
|
|
18
19
|
dependencies: [
|
|
19
20
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
-
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
-
|
|
21
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
22
|
+
],
|
|
23
|
+
path: "ios/Sources/TestPlugin"
|
|
24
|
+
),
|
|
22
25
|
.testTarget(
|
|
23
26
|
name: "TestPluginTests",
|
|
24
27
|
dependencies: ["TestPlugin"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package io.capkit.test
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import io.capkit.test.utils.
|
|
4
|
+
import io.capkit.test.utils.TestLogger
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform-specific native implementation for the Test plugin.
|
|
@@ -14,7 +14,7 @@ import io.capkit.test.utils.Logger
|
|
|
14
14
|
* - handling PluginCall objects
|
|
15
15
|
* - delegating logic to this implementation
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class TestImpl(
|
|
18
18
|
private val context: Context,
|
|
19
19
|
) {
|
|
20
20
|
/**
|
|
@@ -32,8 +32,8 @@ class Test(
|
|
|
32
32
|
*/
|
|
33
33
|
fun updateConfig(newConfig: TestConfig) {
|
|
34
34
|
this.config = newConfig
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
TestLogger.verbose = this.config.verboseLogging
|
|
36
|
+
TestLogger.debug("Configuration updated. Verbose logging: ${this.config.verboseLogging}")
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -43,7 +43,7 @@ class Test(
|
|
|
43
43
|
* and is intentionally side-effect free.
|
|
44
44
|
*/
|
|
45
45
|
fun echo(value: String): String {
|
|
46
|
-
|
|
46
|
+
TestLogger.debug(value)
|
|
47
47
|
return value
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -10,7 +10,7 @@ import com.getcapacitor.PluginCall
|
|
|
10
10
|
import com.getcapacitor.PluginMethod
|
|
11
11
|
import com.getcapacitor.annotation.ActivityCallback
|
|
12
12
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
13
|
-
import io.capkit.test.utils.
|
|
13
|
+
import io.capkit.test.utils.TestLogger
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Capacitor bridge for the Test plugin.
|
|
@@ -33,7 +33,7 @@ class TestPlugin : Plugin() {
|
|
|
33
33
|
/**
|
|
34
34
|
* Native implementation containing platform logic.
|
|
35
35
|
*/
|
|
36
|
-
private lateinit var implementation:
|
|
36
|
+
private lateinit var implementation: TestImpl
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Called once when the plugin is loaded by the Capacitor bridge.
|
|
@@ -47,7 +47,7 @@ class TestPlugin : Plugin() {
|
|
|
47
47
|
super.load()
|
|
48
48
|
|
|
49
49
|
config = TestConfig(this)
|
|
50
|
-
implementation =
|
|
50
|
+
implementation = TestImpl(context)
|
|
51
51
|
implementation.updateConfig(config)
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -61,7 +61,7 @@ class TestPlugin : Plugin() {
|
|
|
61
61
|
@PluginMethod
|
|
62
62
|
fun echo(call: PluginCall) {
|
|
63
63
|
var value = call.getString("value") ?: ""
|
|
64
|
-
|
|
64
|
+
TestLogger.debug("Echoing value: $value")
|
|
65
65
|
|
|
66
66
|
// Append the custom message from the configuration
|
|
67
67
|
value += config.customMessage
|
|
@@ -11,7 +11,7 @@ import android.util.Log
|
|
|
11
11
|
* The goal is to avoid scattering `if (verbose)` checks across
|
|
12
12
|
* business logic and keep logging behavior consistent.
|
|
13
13
|
*/
|
|
14
|
-
object
|
|
14
|
+
object TestLogger {
|
|
15
15
|
/**
|
|
16
16
|
* Logcat tag used for all plugin logs.
|
|
17
17
|
* Helps filtering logs during debugging.
|
|
@@ -17,7 +17,7 @@ public class TestPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
17
17
|
private var config: TestConfig?
|
|
18
18
|
|
|
19
19
|
/// An instance of the implementation class that contains the plugin's core functionality.
|
|
20
|
-
private let implementation =
|
|
20
|
+
private let implementation = TestImpl()
|
|
21
21
|
|
|
22
22
|
/// The unique identifier for the plugin.
|
|
23
23
|
public let identifier = "TestPlugin"
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import XCTest
|
|
2
2
|
@testable import TestPlugin
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
Basic functional tests for the Test plugin native implementation.
|
|
6
|
+
|
|
7
|
+
These tests validate the core behavior of the implementation
|
|
8
|
+
independently from the Capacitor bridge.
|
|
9
|
+
*/
|
|
4
10
|
class TestTests: XCTestCase {
|
|
5
11
|
func testEcho() {
|
|
6
12
|
// This is an example of a functional test case for a plugin.
|
|
7
13
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
8
14
|
|
|
9
|
-
let implementation =
|
|
15
|
+
let implementation = TestImpl()
|
|
10
16
|
let value = "Hello, World!"
|
|
11
17
|
let result = implementation.echo(value)
|
|
12
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-kit/test-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Test plugin for Cap-Kit.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"ios/Sources",
|
|
14
14
|
"ios/Tests",
|
|
15
15
|
"Package.swift",
|
|
16
|
-
"
|
|
16
|
+
"CapKitTest.podspec",
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"author": "Fabio Martino",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"verify": "pnpm run verify:ios && pnpm run verify:android && pnpm run verify:web",
|
|
71
|
-
"verify:ios": "xcodebuild -scheme
|
|
71
|
+
"verify:ios": "xcodebuild -scheme CapKitTest -destination generic/platform=iOS",
|
|
72
72
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
73
73
|
"verify:web": "pnpm run build",
|
|
74
74
|
"lint:android": "cd android && ./gradlew ktlintCheck",
|
|
File without changes
|