var assert = require('assert');
var route = require('../../src/js/route');

namedRoutes = JSON.parse('{"home":{"uri":"\/","methods":["GET","HEAD"],"domain":null},"test":{"uri":"user\/{id}","methods":["GET","HEAD"],"domain":"{account}.myapp.com"},"posts.index":{"uri":"posts","methods":["GET","HEAD"],"domain":null},"posts.show":{"uri":"posts\/{id}\/test\/{test}","methods":["GET","HEAD"],"domain":null},"posts.update":{"uri":"posts\/{id}","methods":["PUT"],"domain":null},"posts.store":{"uri":"posts","methods":["POST"],"domain":null},"posts.destroy":{"uri":"posts\/{id}","methods":["DELETE"],"domain":null}}'),
    baseUrl = 'http://myapp.dev/';

describe('route()', function() {
    it('Should return URL when run without params on a route without params', function() {
      assert.equal("http://myapp.dev/posts", route.route('posts.index'));
    });
});
var assert = require('assert');
var route = require('../../src/js/route');

namedRoutes = JSON.parse('{"home":{"uri":"\/","methods":["GET","HEAD"],"domain":null},"team.user.show":{"uri":"users\/{id}","methods":["GET","HEAD"],"domain":"{team}.myapp.dev"},"posts.index":{"uri":"posts","methods":["GET","HEAD"],"domain":null},"posts.show":{"uri":"posts\/{id}","methods":["GET","HEAD"],"domain":null},"posts.update":{"uri":"posts\/{id}","methods":["PUT"],"domain":null},"posts.store":{"uri":"posts","methods":["POST"],"domain":null},"posts.destroy":{"uri":"posts\/{id}","methods":["DELETE"],"domain":null}}'),
    baseUrl = 'http://myapp.dev/';

describe('route()', function() {
    it('Should return URL when run without params on a route without params', function() {
        assert.equal(
            "http://myapp.dev/posts",
            route.route('posts.index')
        );
    });
    
    it('Should return missing params error when run with missing params on a route with required params', function() {
        assert.throws(
            () => route.route('posts.show'),
            /\"id\" key is required/
        );
    });

    it('Should return URL when run with params on a route with required params', function() {
        assert.equal(
            "http://myapp.dev/posts/1",
            route.route('posts.show', {id: 1})
        );
    });

    it('Should return correct URL when run with params on a route with required domain params', function() {
        assert.equal(
            "tighten.myapp.dev/users/1",
            route.route('team.user.show', {team: 'tighten', id: 1})
        );
    });
});
Add mocha tests for basic functions of route().