{"size": 1222, "ext": "js", "max_stars_repo_path": "test/activities/ActivityUsageCollectionEntity.js", "max_stars_repo_name": "rgoessl/siren-sdk", "max_stars_repo_stars_event_min_datetime": "2020-08-28T08:35:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-28T08:35:52.000Z", "max_issues_repo_path": "test/activities/ActivityUsageCollectionEntity.js", "max_issues_repo_name": "rgoessl/siren-sdk", "max_issues_repo_issues_event_min_datetime": "2019-04-01T13:15:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T20:34:28.000Z", "max_forks_repo_path": "test/activities/ActivityUsageCollectionEntity.js", "max_forks_repo_name": "rgoessl/siren-sdk", "max_forks_repo_forks_event_min_datetime": "2020-06-11T15:47:11.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-11T15:47:11.000Z"}
{"max_stars_count": 1, "max_issues_count": 265, "max_forks_count": 1, "avg_line_length": 32.1578947368, "max_line_length": 103, "alphanum_fraction": 0.6579378069}
import { ActivityUsageCollectionEntity } from '../../src/activities/ActivityUsageCollectionEntity.js';
import { collection } from './data/collection.js';

describe('ActivityUsageCollectionEntity', () => {
	describe('Basic loading', () => {
		it('Loads collected items', done => {
			const entity = window.D2L.Hypermedia.Siren.Parse(collection);
			const collectionEntity = new ActivityUsageCollectionEntity(entity);

			const itemEntities = [];
			collectionEntity.onItemsChange((item, index) => {
				itemEntities[index] = item;
			});
			setTimeout(() => {
				expect(itemEntities.length).to.equal(2);
				done();
			});
		});

		it('has activity-usage href for collected items', done => {
			const entity = window.D2L.Hypermedia.Siren.Parse(collection);
			const collectionEntity = new ActivityUsageCollectionEntity(entity);

			const itemEntities = [];
			collectionEntity.onItemsChange((item, index) => {
				itemEntities[index] = item;
			});
			setTimeout(() => {
				const itemEntity = itemEntities[0];
				expect(itemEntity.activityUsageHref()).to.equal(
					'https://activities.api.testdomain.d2l/activities/6606_3000_6/usages/6606'
				);
				done();
			});
		});
	});
});
