-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
38 lines (28 loc) · 864 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var should = require("should");
var Serializer = require('./index');
var model = {
username: 'kulakowka',
firstname: 'Anton',
lastname: 'Kulakov',
password: 'qwerty'
}
var collection = [model, model];
var rules = {
'username': true,
'fullname': function() {
return this.firstname + ' ' + this.lastname;
}
}
var Model = Serializer(rules, model);
var Collection = Serializer(rules, collection);
describe('Serializer', function(){
it('Serializer return true data', function(){
Model.should.have.property('username', 'kulakowka');
Model.should.have.property('fullname', 'Anton Kulakov');
Collection.should.be.instanceof(Array).and.have.lengthOf(2);
Collection.map(function(user){
user.should.have.property('username', 'kulakowka');
user.should.have.property('fullname', 'Anton Kulakov');
});
})
})