Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 7f59833

Browse files
committed
Format
1 parent 5ef9571 commit 7f59833

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
const loopForOf = require('../../../lib/logics/parser/loopForOf')
2-
const getJsFormat = require('../test-parser-helper')
1+
const loopForOf = require('../../../lib/logics/parser/loopForOf');
2+
const getJsFormat = require('../test-parser-helper');
33

44
describe('Test var assign', () => {
5-
it('Should return null if not match', () =>{
6-
const test1 = loopForOf("fomo semu foo dari bar")
7-
const test2 = loopForOf("fomo smua foo dar bar")
8-
expect(test1).toBe(null)
9-
expect(test2).toBe(null)
10-
})
5+
it('Should return null if not match', () => {
6+
const test1 = loopForOf('fomo semu foo dari bar');
7+
const test2 = loopForOf('fomo smua foo dar bar');
8+
expect(test1).toBe(null);
9+
expect(test2).toBe(null);
10+
});
1111

12-
it('Should return correctly flexing', () => {
13-
const jsFormat = getJsFormat(`
12+
it('Should return correctly flexing', () => {
13+
const jsFormat = getJsFormat(`
1414
fomo semua foo dari bar
1515
spill foo
1616
udahan
17-
`)
18-
expect(jsFormat).not.toBeNull()
19-
let shouldMatch = [
20-
'for (const foo of bar) {',
21-
'console.log(foo)',
22-
'}'
23-
]
24-
jsFormat.split("\n").every((v, i) => {
25-
if(!shouldMatch[i]) return true;
26-
return expect(v).toContain(shouldMatch[i])
27-
})
28-
})
29-
})
17+
`);
18+
expect(jsFormat).not.toBeNull();
19+
let shouldMatch = ['for (const foo of bar) {', 'console.log(foo)', '}'];
20+
jsFormat.split('\n').every((v, i) => {
21+
if (!shouldMatch[i]) return true;
22+
return expect(v).toContain(shouldMatch[i]);
23+
});
24+
});
25+
});

lib/logics/parser/loopFor.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const loopFor = (msg) => {
2-
let format = /fomo ([a-zA-Z0-9]+) endup ([a-zA-Z0-9]+)/;
3-
let match = msg.match(format);
4-
if (!match) return null;
2+
let format = /fomo ([a-zA-Z0-9]+) endup ([a-zA-Z0-9]+)/;
3+
let match = msg.match(format);
4+
if (!match) return null;
55

6-
return {
7-
exp: `for(let ${match[1]} = 0; ${match[1]} <= ${match[2]}; ${match[1]}++)`,
8-
openGroup: true,
9-
};
6+
return {
7+
exp: `for(let ${match[1]} = 0; ${match[1]} <= ${match[2]}; ${match[1]}++)`,
8+
openGroup: true,
9+
};
1010
};
1111

1212
module.exports = loopFor;

0 commit comments

Comments
 (0)