-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathissues.test.ts
33 lines (32 loc) · 1.46 KB
/
issues.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {Issue, IssueSeverity, SOURCE_NODE_NOT_MAPPED} from "../src";
import i18next from 'i18next';
import {SYNTAX_ERROR} from "../src/parsing";
import {expect} from "chai";
describe('Issues', function() {
it("can be translated",
function () {
i18next.init({
lng: 'en', // if you're using a language detector, do not define the lng option
debug: true,
resources: {
en: {
translation: {
ast: {
transform: {
sourceNotMapped: "Source node not mapped: {{type}}"
}
},
parser: {
syntaxError: "A syntax error occurred!"
}
}
}
}
});
let issue = Issue.syntactic("Unexpected token: foo", IssueSeverity.ERROR, undefined, undefined, SYNTAX_ERROR);
expect(i18next.t(issue.code!)).to.equal("A syntax error occurred!");
issue = Issue.semantic("Node not mapped: SomeNode", IssueSeverity.ERROR, undefined, undefined,
SOURCE_NODE_NOT_MAPPED, [{ name: "nodeType", value: "SomeNode" }]);
expect(i18next.t(issue.code!, { type: issue.args[0].value })).to.equal("Source node not mapped: SomeNode");
});
});