-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
081e765
commit aa7e173
Showing
4 changed files
with
68 additions
and
51 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,56 @@ | ||
/// <reference path="../nodelib/node.js"/> | ||
/// <reference path="../nodelib/lodash.js"/> | ||
/// <reference path="../nodelib/mocha.js"/> | ||
/// <reference path="../nodelib/should.js"/> | ||
/// <reference path="../lib/utils/validation.js"/> | ||
/// <reference path="../lib/utils/transforms.js"/> | ||
|
||
var _ = require('lodash'); | ||
var should = require('should'); | ||
|
||
describe('utils', function () { | ||
describe('transforms', function () { | ||
var transform = require('../lib/utils/transforms'); | ||
|
||
it('should allow the transformation of an object\'s properties', function () { | ||
var original = { | ||
a: 'a', | ||
b: 1, | ||
c: 'c', | ||
d: 'd' | ||
}; | ||
|
||
var expected = { | ||
a: 'aa', | ||
b: 1, | ||
c: 'c', | ||
d: 'd' | ||
}; | ||
|
||
var trans = { | ||
a: { $t: function (value) { return value + value; } }, | ||
b: false, | ||
c: { $t: false } | ||
}; | ||
|
||
transform(trans, '$t', original); | ||
|
||
original.should.eql(expected); | ||
}); | ||
|
||
it('should remove properties where the transform returns undefined', function () { | ||
var original = { | ||
a: 1 | ||
}; | ||
|
||
var expected = { | ||
b: '1' | ||
}; | ||
|
||
var trans = { | ||
a: { $t: function (value) { return undefined; } }, | ||
b: { $t: function (value) { return '1'; } } | ||
}; | ||
}); | ||
}); | ||
}); |
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