-
Notifications
You must be signed in to change notification settings - Fork 242
/
i18n.test.js
51 lines (45 loc) · 1.56 KB
/
i18n.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
39
40
41
42
43
44
45
46
47
48
49
50
51
let should = require('./init.js'), db, User;
describe('i18n', function() {
db = getSchema();
before(function() {
User = db.define('User', {
email: { type: String, index: true, limit: 100 },
name: String
});
User.i18n = {
en: {
validation: {
name: {
presence: 'User name is not present'
},
email: {
presence: 'Email required',
uniqueness: 'Email already taken'
}
}
},
ru: {
validation: {
name: {
},
email: {
presence: 'Электропочта надо',
uniqueness: 'Электропочта уже взят'
}
}
}
};
User.validatesUniquenessOf('email');
User.validatesPresenceOf('name', 'email');
});
it('should hook up localized string', function(done) {
User.create({ email: 'John.Doe@example.com', name: 'John Doe' }, function(err, user) {
User.create({ email: 'John.Doe@example.com' }, function(err, user) {
const errors = user.errors.__localize('ru');
errors.name[0].should.equal('can\'t be blank');
errors.email[0].should.equal('Электропочта уже взят');
done();
});
});
});
});