Skip to content

Commit c04d1e8

Browse files
committed
Add tests about missing getter property
Related JSONPath-Plus#174
1 parent 1369aa0 commit c04d1e8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/test.class.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {checkBuiltInVMAndNodeVM} from '../test-helpers/checkVM.js';
2+
3+
checkBuiltInVMAndNodeVM(function (vmType, setBuiltInState) {
4+
describe(`JSONPath - Properties (${vmType})`, function () {
5+
before(setBuiltInState);
6+
7+
/**
8+
*
9+
*/
10+
class Test1 {
11+
/**
12+
* Test2.
13+
*/
14+
constructor () {
15+
this.test2 = "test2";
16+
}
17+
18+
/**
19+
* Test3.
20+
* @returns {string}
21+
*/
22+
// eslint-disable-next-line class-methods-use-this
23+
get test3 () {
24+
return "test3";
25+
}
26+
}
27+
const json = new Test1();
28+
29+
it("Checking simple property", () => {
30+
assert.equal(
31+
jsonpath({json, path: "$.test2", wrap: false}),
32+
"test2"
33+
);
34+
});
35+
36+
it("Checking getter property", () => {
37+
assert.equal(
38+
jsonpath({json, path: "$.test3", wrap: false}),
39+
"test3"
40+
);
41+
});
42+
});
43+
});

0 commit comments

Comments
 (0)