| 1 | import _annotateAsPure from "../lib/index.js"; |
| 2 | const annotateAsPure = _annotateAsPure.default || _annotateAsPure; |
| 3 | |
| 4 | describe("@babel/helper-annotate-as-pure", () => { |
| 5 | it("will add leading comment", () => { |
| 6 | const node = {}; |
| 7 | annotateAsPure(node); |
| 8 | |
| 9 | expect(node.leadingComments).toEqual([ |
| 10 | { |
| 11 | type: "CommentBlock", |
| 12 | value: "#__PURE__", |
| 13 | }, |
| 14 | ]); |
| 15 | }); |
| 16 | |
| 17 | it("will not add an extra leading comment", () => { |
| 18 | const node = { |
| 19 | leadingComments: [ |
| 20 | { |
| 21 | type: "CommentBlock", |
| 22 | value: "#__PURE__", |
| 23 | }, |
| 24 | ], |
| 25 | }; |
| 26 | |
| 27 | annotateAsPure(node); |
| 28 | |
| 29 | expect(node.leadingComments).toEqual([ |
| 30 | { |
| 31 | type: "CommentBlock", |
| 32 | value: "#__PURE__", |
| 33 | }, |
| 34 | ]); |
| 35 | }); |
| 36 | }); |