cartodb-4.42/lib/assets/test/spec/dashboard/data/group-model.spec.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
const GroupModel = require('dashboard/data/group-model');
const CONFIG_MODEL = require('fixtures/dashboard/config-model.fixture');
describe('dashboard/data/group-model', function () {
describe('when given no attrs', function () {
beforeEach(function () {
this.group = new GroupModel({}, { configModel: CONFIG_MODEL });
});
it('should create an empty users collection', function () {
expect(this.group.users).toBeDefined();
expect(this.group.users.length).toEqual(0);
});
});
describe('when given some attrs', function () {
beforeEach(function () {
this.group = new GroupModel({
id: 'g1',
display_name: 'My Group',
name: 'my_group',
users: [{
id: 'u1',
username: 'pepe'
}]
}, { configModel: CONFIG_MODEL });
});
it('should create a users collection from given members collection', function () {
expect(this.group.users).toBeDefined();
expect(this.group.users.length).toEqual(1);
expect(this.group.users.first().get('username')).toEqual('pepe');
expect(this.group.users.group).toBe(this.group);
});
});
});