This commit is contained in:
2026-05-13 19:58:16 +03:00
commit f5adeb292b
78 changed files with 12024 additions and 0 deletions

42
lib/factory/test/user.js Normal file
View File

@@ -0,0 +1,42 @@
const expect = require('chai').expect
const user = require('../user')
const basic = {
username: 'user.name',
email: 'user@example.gov',
auth_service: 'ldap',
auth_data: 'username-field-reference',
teams: [{
name: 'test',
channels: [{
name: 'channel-1'
}, {
name: 'channel-2'
}]
}]
}
describe('user factory', function() {
it('should produce a valid object', function() {
var u = user(basic)
expect(u).to.be.an('object')
expect(u).to.deep.equal({
type: 'user',
user: basic
})
})
it('should ensure email is valid', function() {
try {
var u = user(Object.assign({}, basic, {
email: 'foo@bar'
}))
expect(u).to.be.undefined
}
catch (e) {
expect(e).to.be.an('error')
expect(e.details[0].message).to.equal('"email" must be a valid email')
}
})
})