1 |
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 | const Builder = require('../src');
|
8 | const Machine = require('../src/Machine');
|
9 | const path = require('path');
|
10 |
|
11 | const contextPath = path.resolve(__dirname, './..').replace(/\\/g, '/');
|
12 | const filePath = path.join(contextPath, 'main').replace(/\\/g, '/');
|
13 |
|
14 | describe('Builder', () => {
|
15 |
|
16 | let builder;
|
17 |
|
18 | beforeEach(() => {
|
19 | builder = new Builder();
|
20 | builder.machine.readers.github.token = process.env.SPEC_GITHUB_TOKEN;
|
21 | });
|
22 |
|
23 | it('should build something', () => {
|
24 | expect(builder.machine instanceof Machine).toBeTruthy();
|
25 | builder.machine.generateLineControlStatements = true;
|
26 | expect(builder.machine.execute('@{__FILE__}:@{__LINE__}'))
|
27 | .toBe('#line 1 "' + filePath + '"\nmain:1');
|
28 | });
|
29 |
|
30 | it('should execute "escape" filter', () => {
|
31 | expect(builder.machine instanceof Machine).toBeTruthy();
|
32 | const res = builder.machine.execute(`"@{'"'|escape}"`);
|
33 | expect(res).toBe(`"\\""`);
|
34 | });
|
35 |
|
36 | it('should execute "base64" filter', () => {
|
37 | expect(builder.machine instanceof Machine).toBeTruthy();
|
38 | const res = builder.machine.execute(`@{"abc"|base64}`);
|
39 | expect(res).toBe(`YWJj`);
|
40 | });
|
41 |
|
42 | });
|