Skip to content

Commit

Permalink
adding test cases for call edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Nov 23, 2020
1 parent 027625d commit 263ce53
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,38 @@ void testCallSingle() {
matchVar("first", get("second"));
}

@Test
void testCallSingleThatReturnsJson() {
run(
"def res = karate.callSingle('called3.js')"
);
matchVar("res", "{ varA: '2', varB: '3' }");
}

@Test
void testKarateCallThatReturnsJson() {
run(
"def res = karate.call('called3.js')"
);
matchVar("res", "{ varA: '2', varB: '3' }");
}

@Test
void testCallSingleWithinJs() {
run(
"def res = karate.call('called3-caller1.js')"
);
matchVar("res", "{ varA: '2', varB: '3' }");
}

@Test
void testKarateCallWithinJs() {
run(
"def res = karate.call('called3-caller2.js')"
);
matchVar("res", "{ varA: '2', varB: '3' }");
}

@Test
void testCallFromJs() {
run(
Expand Down Expand Up @@ -646,12 +678,12 @@ void testJavaInteropParameters() {
"def res1 = Utils.fromInt(2)",
"def res2 = Utils.fromDouble(2)",
"def res3 = Utils.fromDouble(2.0)",
"def res4 = Utils.fromNumber(2.0)"
"def res4 = Utils.fromNumber(2.0)"
);
matchVar("res1", "value is 2");
matchVar("res2", "value is 2.0");
matchVar("res3", "value is 2.0");
matchVar("res4", "value is 2.0");
matchVar("res4", "value is 2.0");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function() {
var result = karate.callSingle('called3.js');
// karate.log('result:', result);
return result;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function() {
var result = karate.call('called3.js');
// karate.log('result:', result);
return result;
}
8 changes: 8 additions & 0 deletions karate-core/src/test/java/com/intuit/karate/core/called3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function fn() {
var A = '2';
var B = '3';
return {
varA: A,
varB: B
}
}

0 comments on commit 263ce53

Please sign in to comment.