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 tests for utilities object and cleanup method
- Loading branch information
1 parent
9b12717
commit 0a30d81
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
define( function utilitiesTestModule(require) { | ||
var QUnit = require('qunit'); | ||
var $ = require('jquery'); | ||
|
||
require('fuelux/utilities'); | ||
|
||
QUnit.module( 'Fuel UX Utilities', function utilitiesTests() { | ||
QUnit.test( 'should be defined on jquery object', function utilitiesObjectDefinedTest( assert ) { | ||
assert.equal(typeof $().utilities, 'object', 'utilities object is defined' ); | ||
}); | ||
|
||
QUnit.module( 'cleanInput Method', { | ||
beforeEach: function beforeEachUtilitiesCleanInputTests() { | ||
this.utilities = $().utilities; | ||
this.cleanInput = this.utilities.cleanInput; | ||
} | ||
}, function utilitiesCleanInputTests() { | ||
QUnit.test( 'should be defined on utilities object', function cleanInputMethodDefinedTest( assert ) { | ||
assert.equal(typeof this.utilities.cleanInput, 'function', 'cleanInput function is defined' ); | ||
}); | ||
|
||
QUnit.test( 'should encode strings', function cleanInputMethodEncodeTest( assert ) { | ||
var dirtyString = '<script>'; | ||
var cleanString = '<script>'; | ||
assert.equal(this.cleanInput(dirtyString), cleanString, 'string should be encoded' ); | ||
}); | ||
|
||
QUnit.test( 'should not double encode strings', function cleanInputMethodEncodeTest( assert ) { | ||
var variants = [ | ||
{dirtyString: '<>', cleanString: '<>'}, | ||
{dirtyString: '<script>', cleanString: '<script>'}, | ||
{dirtyString: '<<>>', cleanString: '<<>>'} | ||
]; | ||
|
||
variants.forEach(function forEachDoubleEncodeVariant(variant, index) { | ||
assert.equal(this.cleanInput(variant.dirtyString), variant.cleanString, 'variant ' + (index + 1) + ' string should be encoded' ); | ||
}, this); | ||
}); | ||
}); | ||
}); | ||
}); |