|
| 1 | +var JqueryUi = require( "../lib/jquery-ui" ), |
| 2 | + semver = require( "semver" ); |
| 3 | + |
| 4 | +function notNull( data ) { |
| 5 | + if ( data instanceof Buffer ) { |
| 6 | + data = data.toString( "utf-8" ); |
| 7 | + } |
| 8 | + if ( typeof data === "string" && data.length > 0 ) { |
| 9 | + return true; |
| 10 | + } |
| 11 | + return false; |
| 12 | +} |
| 13 | + |
| 14 | +var tests = { |
| 15 | + "test: common files present": function( test ) { |
| 16 | + var files = this.jqueryUi.files(); |
| 17 | + test.expect( files.commonFiles.length ); |
| 18 | + files.commonFiles.forEach(function( file ) { |
| 19 | + test.ok( notNull( file.data ), "Null file \"" + file.path + "\"." ); |
| 20 | + }); |
| 21 | + test.done(); |
| 22 | + }, |
| 23 | + "test: component files present": function( test ) { |
| 24 | + var files = this.jqueryUi.files(); |
| 25 | + test.expect( files.componentFiles.length ); |
| 26 | + files.componentFiles.forEach(function( file ) { |
| 27 | + test.ok( notNull( file.data ), "Null file \"" + file.path + "\"." ); |
| 28 | + }); |
| 29 | + test.done(); |
| 30 | + }, |
| 31 | + "test: demo files present": function( test ) { |
| 32 | + var files = this.jqueryUi.files(); |
| 33 | + test.expect( files.demoFiles.length ); |
| 34 | + files.demoFiles.forEach(function( file ) { |
| 35 | + test.ok( notNull( file.data ), "Null file \"" + file.path + "\"." ); |
| 36 | + }); |
| 37 | + test.done(); |
| 38 | + }, |
| 39 | + "test: doc files present": function( test ) { |
| 40 | + var files = this.jqueryUi.files(); |
| 41 | + test.expect( files.docFiles.length ); |
| 42 | + files.docFiles.forEach(function( file ) { |
| 43 | + test.ok( notNull( file.data ), "Null file \"" + file.path + "\"." ); |
| 44 | + }); |
| 45 | + test.done(); |
| 46 | + }, |
| 47 | + "test: base theme files present": function( test ) { |
| 48 | + var files = this.jqueryUi.files(); |
| 49 | + test.expect( files.baseThemeFiles.length ); |
| 50 | + files.baseThemeFiles.forEach(function( file ) { |
| 51 | + test.ok( notNull( file.data ), "Null file \"" + file.path + "\"." ); |
| 52 | + }); |
| 53 | + test.done(); |
| 54 | + } |
| 55 | +}; |
| 56 | + |
| 57 | +module.exports = {}; |
| 58 | + |
| 59 | +// Build tests for each jqueryUi release |
| 60 | +JqueryUi.all().filter(function(jqueryUi) { |
| 61 | + // Filter supported releases only |
| 62 | + return semver.lt( jqueryUi.pkg.version, "1.11.0-a" ); |
| 63 | +}).forEach(function( jqueryUi ) { |
| 64 | + function deepTestBuild( obj, tests ) { |
| 65 | + Object.keys( tests ).forEach(function( i ) { |
| 66 | + if ( typeof tests[ i ] === "object" ) { |
| 67 | + obj[ i ] = {}; |
| 68 | + deepTestBuild( obj[ i ], tests[ i ] ); |
| 69 | + } else { |
| 70 | + obj[ i ] = function( test ) { |
| 71 | + tests[ i ].call({ |
| 72 | + jqueryUi: jqueryUi |
| 73 | + }, test ); |
| 74 | + }; |
| 75 | + } |
| 76 | + }); |
| 77 | + } |
| 78 | + module.exports[ jqueryUi.pkg.version ] = {}; |
| 79 | + deepTestBuild( module.exports[ jqueryUi.pkg.version ], tests ); |
| 80 | +}); |
0 commit comments