1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | const assert = require('assert');
|
15 | const s = require('../lib/symbols');
|
16 | const { gentitle, gendescription } = require('../lib/formattingTools');
|
17 |
|
18 | describe('Testing formatting tools: gettitle', () => {
|
19 | it('robust for undefined', () => {
|
20 | assert.strictEqual(gentitle('foo'), 'Untitled schema');
|
21 | });
|
22 | it('robust for non array', () => {
|
23 | assert.strictEqual(gentitle('foo'), 'Untitled schema');
|
24 | });
|
25 | it('robust for undefined array', () => {
|
26 | assert.strictEqual(gentitle([undefined]), 'Untitled schema');
|
27 | });
|
28 | it('robust for larger undefined array', () => {
|
29 | assert.strictEqual(gentitle([undefined, undefined]), 'Untitled schema');
|
30 | });
|
31 | it('returns single first title', () => {
|
32 | assert.strictEqual(gentitle(['Hello world schema']), 'Hello world schema');
|
33 | });
|
34 | it('returns last title', () => {
|
35 | assert.strictEqual(gentitle([1, 2, 3, 'Hello world schema']), 'Hello world schema');
|
36 | });
|
37 | it('returns title with type', () => {
|
38 | assert.strictEqual(gentitle(['Hello world schema', undefined], 'string'),
|
39 | 'Untitled string in Hello world schema');
|
40 | });
|
41 | it('returns title with for undefined type', () => {
|
42 | assert.strictEqual(gentitle(['Hello world schema', undefined]),
|
43 | 'Untitled undefined type in Hello world schema');
|
44 | });
|
45 | });
|
46 |
|
47 | describe('Testing formatting tools: gendescription', () => {
|
48 | it('robust for undefined', () => {
|
49 | assert.strictEqual(gendescription(), '');
|
50 | });
|
51 |
|
52 | it('works with meta', () => {
|
53 | assert.strictEqual(gendescription({
|
54 | [s.meta]: {
|
55 | shortdescription: 'Hello, world',
|
56 | },
|
57 | }), 'Hello, world');
|
58 | });
|
59 | });
|