This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add commonJS test and dist file generation
This creates a test like the Browser globals test that detects if the CommonJS bundle created with browserify has initialized the plugins. It gitignores the bundled file that is created within the validate-dist task.
- Loading branch information
1 parent
8a45e2c
commit 547fbd1
Showing
5 changed files
with
200 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*! | ||
* Bootstrap Grunt task for the CommonJS module generation | ||
* http://getbootstrap.com | ||
* Copyright 2014-2015 Twitter, Inc. | ||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var banner = '// This file has been created by the `commonjs` Grunt task.' + | ||
' You can require() this file in a CommonJS environment.\n' + | ||
'require(\'jquery\');\n' + | ||
'require(\'bootstrap\');\n\n'; | ||
'require(\'moment\');\n\n'; | ||
|
||
module.exports = function createBundledReferenceModule(grunt, files, destFile) { | ||
var destDir = path.dirname(destFile); | ||
|
||
function srcPathToDestRequire(files) { | ||
var requirePath = path.relative(destDir, files).replace(/\\/g, '/').replace(/\.js$/g, ''); | ||
return 'require(\'' + requirePath + '\');'; | ||
} | ||
|
||
var moduleOutputJs = banner + files.map(srcPathToDestRequire).join('\n'); | ||
try { | ||
fs.writeFileSync(destFile, moduleOutputJs); | ||
} catch (err) { | ||
grunt.fail.warn(err); | ||
} | ||
grunt.log.writeln('CommonJS Bundled Reference file created: ' + destFile.cyan); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
window.$ = window.jQuery = require('jquery'); | ||
var bootstrap = require('bootstrap'); | ||
var moment = require('moment'); | ||
var fuelux = require('../dist/js/npm'); | ||
var QUnit = require('qunitjs'); | ||
|
||
// In order to be be UMD compliant, modules must work with | ||
// CommonJS. The following tests check to see if the plugin | ||
// is on the jQuery namespace and nothing else. | ||
|
||
test('combobox should be defined on jQuery object', function () { | ||
ok($().combobox, 'combobox method is defined'); | ||
}); | ||
|
||
test('datepicker should be defined on the jQuery object', function () { | ||
ok($().datepicker, 'datepicker method is defined'); | ||
}); | ||
|
||
test('dropdownautoflip should be defined on the jQuery object', function () { | ||
ok($().dropdownautoflip, 'dropdownautoflip method is defined'); | ||
}); | ||
|
||
test('infinitescroll should be defined on the jQuery object', function () { | ||
ok($().infinitescroll, 'infinitescroll method is defined'); | ||
}); | ||
|
||
test('loader should be defined on the jQuery object', function () { | ||
ok($().loader, 'loader method is defined'); | ||
}); | ||
|
||
test('pillbox should be defined on jQuery object', function () { | ||
ok($().pillbox, 'pillbox method is defined'); | ||
}); | ||
|
||
test('radio should be defined on jQuery object', function () { | ||
ok($().radio, 'radio method is defined'); | ||
}); | ||
|
||
test('repeater should be defined on jQuery object', function () { | ||
ok($().repeater, 'repeater method is defined'); | ||
}); | ||
|
||
test('repeater list should be defined on jQuery object', function () { | ||
ok($.fn.repeater.viewTypes.list, 'repeater list view is defined'); | ||
}); | ||
|
||
test('repeater thumbnail should be defined on jQuery object', function () { | ||
ok($.fn.repeater.viewTypes.thumbnail, 'repeater thumbnail view is defined'); | ||
}); | ||
|
||
test('scheduler should be defined on the jQuery object', function () { | ||
ok($().scheduler, 'scheduler method is defined'); | ||
}); | ||
|
||
test('search should be defined on jQuery object', function () { | ||
ok($().search, 'search method is defined'); | ||
}); | ||
|
||
test('selectlist should be defined on jQuery object', function () { | ||
ok($().selectlist, 'selectlist method is defined'); | ||
}); | ||
|
||
test('spinbox should be defined on jQuery object', function () { | ||
ok($().spinbox, 'spinbox method is defined'); | ||
}); | ||
|
||
test('tree should be defined on jQuery object', function () { | ||
ok($().tree, 'tree method is defined'); | ||
}); | ||
|
||
test('wizard should be defined on jQuery object', function () { | ||
ok($().wizard, 'wizard method is defined'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>FuelUX Component Initialization (via CommonJS)</title> | ||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css" media="screen"> | ||
</head> | ||
<body> | ||
<h1 id="qunit-header">Fuel UX CommonJS Test Suite</h1> | ||
|
||
<h2 id="qunit-banner"></h2> | ||
|
||
<div id="qunit-testrunner-toolbar"></div> | ||
<h2 id="qunit-userAgent"></h2> | ||
<ol id="qunit-tests"></ol> | ||
<div id="qunit-fixture"></div> | ||
|
||
<script src="commonjs-bundle.js"></script> | ||
|
||
</body> | ||
</html> |