/*
 * Optics test / subcommand.js
 * copyright (c) 2016 Susisu
 */

"use strict";

describe("subcommand", () => {
    describe("Subcommand", () => {
        describe("constructor(name, cmd)", () => {
            it("should create a new Subcommand instance");
            it("should throw a TypeError if 'name' is not a string");
            it("should throw a TypeError if 'cmd' is not an instance of CommandBase");
        });
    });

    describe("CommandGroup", () => {
        describe("constructor(desc, subcmds, defaultCmd)", () => {
            it("should create a new CommandGroup instance");
            it("should throw a TypeError if 'desc' is not a string");
            it("should throw a TypeError if 'subcmds' is not an array of Subcommand");
            it("should throw a TypeError if 'defaultCmd' is not an instance of CommandBase nor null");
        });
    });
});

@@ -76,16 +76,179 @@
 rict%22;%0A%0A
+const chai   = require(%22chai%22);%0Aconst expect = chai.expect;%0A%0Aconst command    = require(%22../lib/command.js%22);%0Aconst subcommand = require(%22../lib/subcommand.js%22);%0A%0A
 describe
@@ -416,165 +416,2254 @@
 nce%22
-);%0A            it(%22should throw a TypeError if 'name' is not a string%22);%0A            it(%22should throw a TypeError if 'cmd' is not an instance of CommandBase%22
+, () =%3E %7B%0A                let cmd = new command.Command(%0A                    %22test command%22,%0A                    %5B%5D,%0A                    %5B%5D,%0A                    (args, opts) =%3E %7B%7D%0A                );%0A                let subcmd = new subcommand.Subcommand(%22test%22, cmd);%0A                expect(subcmd).to.be.an.instanceOf(subcommand.Subcommand);%0A            %7D);%0A%0A            it(%22should throw a TypeError if 'name' is not a string%22, () =%3E %7B%0A                let cmd = new command.Command(%0A                    %22test command%22,%0A                    %5B%5D,%0A                    %5B%5D,%0A                    (args, opts) =%3E %7B%7D%0A                );%0A                function construct(name) %7B%0A                    return () =%3E %7B%0A                        new subcommand.Subcommand(name, cmd);%0A                    %7D;%0A                %7D%0A                expect(construct(%22test%22)).not.to.throw(TypeError);%0A%0A                expect(construct(null)).to.throw(TypeError);%0A                expect(construct(undefined)).to.throw(TypeError);%0A                expect(construct(3.14)).to.throw(TypeError);%0A                expect(construct(true)).to.throw(TypeError);%0A                expect(construct(%7B%7D)).to.throw(TypeError);%0A                expect(construct(() =%3E %7B%7D)).to.throw(TypeError);%0A            %7D);%0A%0A            it(%22should throw a TypeError if 'cmd' is not an instance of CommandBase%22, () =%3E %7B%0A                let cmd = new command.Command(%0A                    %22test command%22,%0A                    %5B%5D,%0A                    %5B%5D,%0A                    (args, opts) =%3E %7B%7D%0A                );%0A                function construct(cmd) %7B%0A                    return () =%3E %7B%0A                        new subcommand.Subcommand(%22test%22, cmd);%0A                    %7D;%0A                %7D%0A                expect(construct(cmd)).not.to.throw(TypeError);%0A%0A                expect(construct(null)).to.throw(TypeError);%0A                expect(construct(undefined)).to.throw(TypeError);%0A                expect(construct(%22foobar%22)).to.throw(TypeError);%0A                expect(construct(3.14)).to.throw(TypeError);%0A                expect(construct(true)).to.throw(TypeError);%0A                expect(construct(%7B%7D)).to.throw(TypeError);%0A                expect(construct(() =%3E %7B%7D)).to.throw(TypeError);%0A            %7D
 );%0A 

Add tests for the Subcommand constructor