Permalink
Browse files

Remove type checks, tighten up tests toBe

  • Loading branch information...
1 parent 8e894f2 commit e021d55e3c53815b8bd93aa0ed7e8259c628fbf0 @iamdustan iamdustan committed Dec 6, 2012
Showing with 7 additions and 13 deletions.
  1. +0 −6 src/tools.js
  2. +7 −7 test/tools-spec.js
View
@@ -349,10 +349,6 @@ define([], function() {
* @returns {String} unit
*/
extractUnit: function (any) {
- if (typeof any === 'undefined' || typeof any === 'number') {
- return '';
- }
-
// make sure it's a string and remove trailing whitespace
var unit = String(any).replace(/\s+$/, '');
// returns extracted unit or empty string
@@ -381,8 +377,6 @@ define([], function() {
radians = amount * PI / 200; break;
case 'turn':
radians = amount * 2 * PI; break;
- default:
- radians = 0;
}
return radians;
View
@@ -293,49 +293,49 @@ define([
var returned = extractUnit('9deg');
var expected = 'deg';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
it('should work with negative numbers', function() {
var returned = extractUnit('-741232grad');
var expected = 'grad';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
it('should work with trailing whitespace', function() {
var returned = extractUnit('-741232grad ');
var expected = 'grad';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
it('should work with leading whitespace', function() {
var returned = extractUnit('-741232 grad ');
var expected = 'grad';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
it('should return an empty string in case of a number', function () {
var returned = extractUnit(7531);
var expected = '';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
it('should return the string when given an array', function () {
var returned = extractUnit(['50s']);
var expected = 's';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
it('should work with percentages', function () {
var returned = extractUnit('50%');
var expected = '%';
- expect(returned).toEqual(expected);
+ expect(returned).toBe(expected);
});
});

0 comments on commit e021d55

Please sign in to comment.