Issues (204)

test/InterfaceBuilder/InterfaceBuilderTest.js (1 issue)

Severity
1
/* Javascript Object Inheritance Implementation                ______  ________
2
 * (c) 2016 <[email protected]>                             __ / / __ \/  _/  _/
3
 * Licensed under MIT.                                    / // / /_/ // /_/ /
4
 * ------------------------------------------------------ \___/\____/___/__*/
5
var JOII = require('../../dist/joii').JOII;
6
7
/**
8
 * This test does NOT test validation of interfaces on classes, but instead
9
 * tests the final result of the interface function based on the parameters
10
 * given to the InterfaceBuilder.
11
 */
12
test('InterfaceBuilder:InterfaceBuilderTest', function(assert) {
13
14
    var testDefinition = function(i, name) {
0 ignored issues
show
This function should enable strict mode with use strict.

Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors.

Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations.

We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website.

Loading history...
15
        assert.equal(typeof(i), 'function', 'Interface is available as a function.');
16
        assert.equal(typeof(i.definition), 'function', 'Interface definition is available as a function.');
17
        assert.equal(typeof(i.definition.__interface__), 'object', 'Interface metadata is available as an object.');
18
        assert.equal(typeof(i.definition.__interface__.name), 'string', 'Interface name is available as a string.');
19
        assert.equal(typeof(i.definition.__interface__.reflector), 'object', 'Interface definition reflector is available as an object.');
20
        assert.equal(typeof(i.definition.__interface__.prototype), 'object', 'Interface definition prototype is available as an object.');
21
        if (typeof(name) !== 'undefined') {
22
            assert.equal(i.definition.__interface__.name, name, 'Interface name is OK.');
23
        }
24
    };
25
26
    // Test empty interfaces
27
    testDefinition(JOII.InterfaceBuilder({}));
28
    testDefinition(JOII.InterfaceBuilder({}, {}));
29
    testDefinition(JOII.InterfaceBuilder('empty', {}, {}), 'empty');
30
    testDefinition(JOII.InterfaceBuilder('SomeInterfaceName'), 'SomeInterfaceName');
31
    testDefinition(JOII.InterfaceBuilder('AnotherInterfaceName', {}), 'AnotherInterfaceName');
32
});
33