|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const { expect } = require("chai"); |
| 4 | + |
| 5 | +const javaParser = require("../src/index"); |
| 6 | + |
| 7 | +describe("The Java Parser should parse TextBlocks", () => { |
| 8 | + it("should not parse a one word 'TextBlock'", () => { |
| 9 | + const input = `"""word"""`; |
| 10 | + |
| 11 | + expect(() => javaParser.parse(input, "literal")).to.throw(); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should not parse a one word 'TextBlock' with starting spaces", () => { |
| 15 | + const input = `""" word"""`; |
| 16 | + |
| 17 | + expect(() => javaParser.parse(input, "literal")).to.throw(); |
| 18 | + }); |
| 19 | + |
| 20 | + it("should parse a one word 'TextBlock' starting with new line", () => { |
| 21 | + const input = `""" |
| 22 | + one"""`; |
| 23 | + |
| 24 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 25 | + }); |
| 26 | + |
| 27 | + it("should parse a one word 'TextBlock' starting with spaces and new line", () => { |
| 28 | + const input = `"""${" "} |
| 29 | + one"""`; |
| 30 | + |
| 31 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 32 | + }); |
| 33 | + |
| 34 | + it("should parse a one line 'TextBlock' starting with new line", () => { |
| 35 | + const input = `""" |
| 36 | + one sentence"""`; |
| 37 | + |
| 38 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 39 | + }); |
| 40 | + |
| 41 | + it("should parse a one line 'TextBlock' starting with spaces and new line", () => { |
| 42 | + const input = `"""${" "} |
| 43 | + one sentence"""`; |
| 44 | + |
| 45 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 46 | + }); |
| 47 | + |
| 48 | + it("should parse a multiline 'TextBlock'", () => { |
| 49 | + const input = `""" |
| 50 | + one word |
| 51 | +
|
| 52 | + sentence |
| 53 | +
|
| 54 | + """`; |
| 55 | + |
| 56 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 57 | + }); |
| 58 | + |
| 59 | + it("should not parse a multiline 'TextBlock' which do not start with new line", () => { |
| 60 | + const input = `"""one word |
| 61 | +
|
| 62 | + sentence |
| 63 | +
|
| 64 | + """`; |
| 65 | + |
| 66 | + expect(() => javaParser.parse(input, "literal")).to.throw(); |
| 67 | + }); |
| 68 | + |
| 69 | + it("should parse a multiline 'TextBlock' with ", () => { |
| 70 | + const input = `""" |
| 71 | + one word |
| 72 | +
|
| 73 | + "sentence" |
| 74 | +
|
| 75 | + """`; |
| 76 | + |
| 77 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 78 | + }); |
| 79 | + |
| 80 | + it("should not parse a 'TextBlock' ending with 4x\"", () => { |
| 81 | + const input = `""" |
| 82 | + one word |
| 83 | +
|
| 84 | + "sentence" |
| 85 | +
|
| 86 | + """"`; |
| 87 | + |
| 88 | + expect(() => javaParser.parse(input, "literal")).to.throw(); |
| 89 | + }); |
| 90 | + |
| 91 | + it("should not parse a 'TextBlock' ending with 4x\"", () => { |
| 92 | + const input = `""" |
| 93 | + one word |
| 94 | +
|
| 95 | + "sentence""" |
| 96 | +
|
| 97 | + ""`; |
| 98 | + |
| 99 | + expect(() => javaParser.parse(input, "literal")).to.throw(); |
| 100 | + }); |
| 101 | + |
| 102 | + it("should not parse a 'TextBlock' ending with 4x\"", () => { |
| 103 | + const input = `""" |
| 104 | + my text |
| 105 | +
|
| 106 | +
|
| 107 | + sentence\\""" |
| 108 | +
|
| 109 | + """ |
| 110 | + `; |
| 111 | + expect(() => javaParser.parse(input, "literal")).to.not.throw(); |
| 112 | + }); |
| 113 | +}); |
0 commit comments