1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | 'use strict';
|
16 |
|
17 | const chai = require('chai');
|
18 | const path = require('path');
|
19 | const tmp = require('tmp-promise');
|
20 | const fs = require('fs');
|
21 |
|
22 | chai.should();
|
23 | chai.use(require('chai-things'));
|
24 | chai.use(require('chai-as-promised'));
|
25 |
|
26 | const Commands = require('../lib/commands');
|
27 |
|
28 | describe('cicero-tools', () => {
|
29 | const models = [path.resolve(__dirname, 'models/dom.cto'),path.resolve(__dirname, 'models/money.cto')];
|
30 |
|
31 | describe('#generate', () => {
|
32 |
|
33 | it('should generate a Go model', async () => {
|
34 | const dir = await tmp.dir({ unsafeCleanup: true});
|
35 | await Commands.generate('Go', models, dir.path, true);
|
36 | fs.readdirSync(dir.path).length.should.be.above(0);
|
37 | dir.cleanup();
|
38 | });
|
39 | it('should generate a PlantUML model', async () => {
|
40 | const dir = await tmp.dir({ unsafeCleanup: true});
|
41 | await Commands.generate('PlantUML', models, dir.path, true);
|
42 | fs.readdirSync(dir.path).length.should.be.above(0);
|
43 | dir.cleanup();
|
44 | });
|
45 | it('should generate a Typescript model', async () => {
|
46 | const dir = await tmp.dir({ unsafeCleanup: true});
|
47 | await Commands.generate('Typescript', models, dir.path, true);
|
48 | fs.readdirSync(dir.path).length.should.be.above(0);
|
49 | dir.cleanup();
|
50 | });
|
51 | it('should generate a Java model', async () => {
|
52 | const dir = await tmp.dir({ unsafeCleanup: true});
|
53 | await Commands.generate('Java', models, dir.path, true);
|
54 | fs.readdirSync(dir.path).length.should.be.above(0);
|
55 | dir.cleanup();
|
56 | });
|
57 | it('should generate a Corda model', async () => {
|
58 | const dir = await tmp.dir({ unsafeCleanup: true});
|
59 | await Commands.generate('Corda', models, dir.path, true);
|
60 | fs.readdirSync(dir.path).length.should.be.above(0);
|
61 | dir.cleanup();
|
62 | });
|
63 | it('should generate a JSONSchema model', async () => {
|
64 | const dir = await tmp.dir({ unsafeCleanup: true});
|
65 | await Commands.generate('JSONSchema', models, dir.path, true);
|
66 | fs.readdirSync(dir.path).length.should.be.above(0);
|
67 | dir.cleanup();
|
68 | });
|
69 | it('should generate a XMLSchema model', async () => {
|
70 | const dir = await tmp.dir({ unsafeCleanup: true});
|
71 | await Commands.generate('XMLSchema', models, dir.path, true);
|
72 | fs.readdirSync(dir.path).length.should.be.above(0);
|
73 | dir.cleanup();
|
74 | });
|
75 | it('should not generate an unknown model', async () => {
|
76 | const dir = await tmp.dir({ unsafeCleanup: true});
|
77 | await Commands.generate('BLAH', models, dir.path, true);
|
78 | fs.readdirSync(dir.path).length.should.be.equal(0);
|
79 | dir.cleanup();
|
80 | });
|
81 | });
|
82 | }); |
\ | No newline at end of file |