@flash-ai-team/flash-test-framework 0.0.11 → 0.0.12
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.
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare function TestCase(target:
|
|
2
|
-
export declare function TestCase(
|
|
1
|
+
export declare function TestCase(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
2
|
+
export declare function TestCase<This, Args extends any[], Return>(target: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>): (this: This, ...args: Args) => Return;
|
|
3
|
+
export declare function TestCase(): any;
|
|
@@ -43,39 +43,52 @@ function getCallerFile() {
|
|
|
43
43
|
}
|
|
44
44
|
return '';
|
|
45
45
|
}
|
|
46
|
-
function TestCase(
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
legacyDescriptor
|
|
46
|
+
function TestCase(arg1, arg2, arg3) {
|
|
47
|
+
// Helper to apply the logic (shared between factory and direct call)
|
|
48
|
+
const applyDecorator = (targetOrValue, contextOrKey, descriptor) => {
|
|
49
|
+
// Stage 3: (value, context)
|
|
50
|
+
if (typeof contextOrKey === 'object' && contextOrKey !== null && 'kind' in contextOrKey) {
|
|
51
|
+
const originalMethod = targetOrValue;
|
|
52
|
+
const context = contextOrKey;
|
|
53
|
+
const methodName = String(context.name);
|
|
54
|
+
const definitionFile = getCallerFile();
|
|
55
|
+
return async function (...args) {
|
|
56
|
+
test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
|
|
57
|
+
if (definitionFile) {
|
|
58
|
+
test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
|
|
59
|
+
}
|
|
60
|
+
return await originalMethod.apply(this, args);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Legacy: (target, propertyKey, descriptor)
|
|
64
|
+
let legacyDescriptor = descriptor;
|
|
65
|
+
if (!legacyDescriptor && typeof contextOrKey === 'string') {
|
|
66
|
+
legacyDescriptor = Object.getOwnPropertyDescriptor(targetOrValue, contextOrKey);
|
|
67
|
+
}
|
|
68
|
+
if (legacyDescriptor) {
|
|
69
|
+
const originalMethod = legacyDescriptor.value;
|
|
70
|
+
const methodName = contextOrKey;
|
|
71
|
+
const definitionFile = getCallerFile();
|
|
72
|
+
legacyDescriptor.value = async function (...args) {
|
|
73
|
+
test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
|
|
74
|
+
if (definitionFile) {
|
|
75
|
+
test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
|
|
76
|
+
}
|
|
77
|
+
return await originalMethod.apply(this, args);
|
|
78
|
+
};
|
|
79
|
+
return legacyDescriptor;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
// Determine usage type
|
|
83
|
+
const isDirectCall = (arg2 && typeof arg2 === 'string') || // Legacy: (target, key)
|
|
84
|
+
(arg2 && typeof arg2 === 'object' && 'kind' in arg2); // Stage 3: (value, context)
|
|
85
|
+
if (isDirectCall) {
|
|
86
|
+
return applyDecorator(arg1, arg2, arg3);
|
|
66
87
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const definitionFile = getCallerFile();
|
|
72
|
-
legacyDescriptor.value = async function (...args) {
|
|
73
|
-
test_1.test.info().annotations.push({ type: 'MethodName', description: methodName });
|
|
74
|
-
if (definitionFile) {
|
|
75
|
-
test_1.test.info().annotations.push({ type: 'SourceFile', description: definitionFile });
|
|
76
|
-
}
|
|
77
|
-
return await originalMethod.apply(this, args);
|
|
88
|
+
else {
|
|
89
|
+
// Factory usage: @TestCase()
|
|
90
|
+
return function (target, key, descriptor) {
|
|
91
|
+
return applyDecorator(target, key, descriptor);
|
|
78
92
|
};
|
|
79
|
-
return legacyDescriptor;
|
|
80
93
|
}
|
|
81
94
|
}
|