UNPKG

3.4 kBJavaScriptView Raw
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15'use strict';
16
17const chai = require('chai');
18const path = require('path');
19const tmp = require('tmp-promise');
20const fs = require('fs');
21
22chai.should();
23chai.use(require('chai-things'));
24chai.use(require('chai-as-promised'));
25
26const Commands = require('../lib/commands');
27
28describe('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