Files
threshold-ui/ui/core/mirage/factories/scope.js
T

35 lines
803 B
JavaScript
Raw Normal View History

import factory from '../generated/factories/scope';
import { trait } from 'ember-cli-mirage';
export default factory.extend({
type: 'global',
2020-10-01 16:51:16 -04:00
/**
* Generates realistic-ish IDs while still being deterministic.
*/
id(i) {
let id = 'tv6fv3yz8p';
if (i % 3) id = 'xk1i4dk50v';
if (i % 2) id = 's9n819zgko';
return `s_${id}${i}`;
2020-10-01 16:31:39 -04:00
},
withChildren: trait({
afterCreate(record, server) {
if (record.type === 'global') {
server.createList('scope', 1, {
type: 'org',
scope: { id: record.id, type: record.type }
}, 'withChildren');
}
if (record.type === 'org') {
2020-08-14 10:46:17 -04:00
server.createList('scope', 3, {
type: 'project',
scope: { id: record.id, type: record.type }
});
}
}
})
});