UNPKG

bod

Version:
66 lines (65 loc) 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../index"); describe('commands', () => { let commands; let counts; beforeEach(() => { commands = new Set([ new index_1.BaseCommand({ name: 'base', description: 'Base command description', usage: 'base', }), new index_1.CreateCommand(), new index_1.InfoCommand(), ]); counts = new Map(); }); afterEach(() => { commands.clear(); counts.clear(); }); it('should has unique name', () => { for (const command of commands) { const name = command.getName(); if (counts.has(name)) counts.set(name, counts.get(name) + 1); else counts.set(name, 1); expect(command).toBeDefined(); } for (const [name, count] of counts) { expect(name).toBeTruthy(); expect(count).toBe(1); } }); it('should has unique usage', () => { for (const command of commands) { const usage = command.getUsage(); if (counts.has(usage)) counts.set(usage, counts.get(usage) + 1); else counts.set(usage, 1); expect(command).toBeDefined(); } for (const [usage, count] of counts) { expect(usage).toBeTruthy(); expect(count).toBe(1); } }); it('should has unique alias', () => { for (const command of commands) { const alias = command.getAlias(); if (counts.has(alias)) counts.set(alias, counts.get(alias) + 1); else counts.set(alias, 1); expect(command).toBeDefined(); } for (const [alias, count] of counts) { expect(alias).toBeTruthy(); expect(count).toBe(1); } }); });