-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfixText.js
41 lines (37 loc) · 1.14 KB
/
fixText.js
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
34
35
36
37
38
39
40
41
/* eslint-disable max-nested-callbacks */
import {
expect
} from 'chai';
import {
fixText
} from './../../src';
describe('utilities', () => {
describe('fixText', () => {
context('unrecognized syntax', () => {
it('throws an error', () => {
expect(() => {
fixText('', {
syntax: 'java'
});
}).to.throw(Error, 'Unknown syntax "java".');
});
});
context('JavaScript syntax', () => {
context('invalid syntax', () => {
it('throws an error', () => {
expect(() => {
fixText('let foo;<>;;', {
syntax: 'js'
});
}).to.throw(Error, 'Parsing error: Unexpected token (line: 1, column: 10).');
});
});
it('fixes syntax error', () => {
const report = fixText('let foo;;;', {
syntax: 'js'
});
expect(report).to.equal('let foo;\n');
});
});
});
});