@@ -4,13 +4,58 @@ var async = require('async');
44var should = require ( 'should' ) ;
55var targets = require ( '../src/targets' ) ;
66
7- async . each ( Object . keys ( targets ) , function ( target ) {
8- describe ( target + '.info()' , function ( ) {
9- it ( 'should have info method' , function ( done ) {
10- targets [ target ] . should . have . property ( 'info' ) ;
11- targets [ target ] . info . should . be . a . Function ;
7+ var isSingleTarget = function ( key , cb ) {
8+ cb ( typeof targets [ key ] === 'function' ) ;
9+ } ;
1210
13- done ( ) ;
11+ var isTargetFamily = function ( key , cb ) {
12+ cb ( typeof targets [ key ] !== 'function' ) ;
13+ } ;
14+
15+ async . filter ( Object . keys ( targets ) , isSingleTarget , function ( results ) {
16+ async . each ( results , function ( key ) {
17+ describe ( key + '.info()' , function ( ) {
18+ it ( 'should have info method' , function ( done ) {
19+ var target = targets [ key ] ;
20+
21+ target . should . have . property ( 'info' ) ;
22+ target . info . should . be . a . Function ;
23+
24+ var info = target . info ( ) ;
25+
26+ info . key . should . be . a . String . and . equal ( key ) ;
27+ info . should . not . have . property ( 'family' ) ;
28+
29+ info . ext . should . be . a . String ;
30+ info . title . should . be . a . String ;
31+
32+ done ( ) ;
33+ } ) ;
34+ } ) ;
35+ } ) ;
36+ } ) ;
37+
38+ async . filter ( Object . keys ( targets ) , isTargetFamily , function ( families ) {
39+ async . each ( families , function ( family ) {
40+ async . each ( Object . keys ( targets [ family ] ) , function ( key ) {
41+ var target = targets [ family ] [ key ] ;
42+
43+ describe ( family + '[' + key + ']' + '.info()' , function ( ) {
44+ it ( 'should have info method' , function ( done ) {
45+ target . should . have . property ( 'info' ) ;
46+ target . info . should . be . a . Function ;
47+
48+ var info = target . info ( ) ;
49+
50+ info . key . should . be . a . String . and . equal ( key ) ;
51+
52+ info . family . should . be . a . String ;
53+ info . ext . should . be . a . String ;
54+ info . title . should . be . a . String ;
55+
56+ done ( ) ;
57+ } ) ;
58+ } ) ;
1459 } ) ;
1560 } ) ;
1661} ) ;
0 commit comments