Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Factory, faker } from 'ember-cli-mirage';
export default Factory.extend({
admin: false,
biography: faker.lorem.paragraph,
email: faker.internet.email,
photoLargeUrl: faker.image.avatar,
photoThumbUrl: faker.image.avatar,
twitter: faker.internet.domainWord,
username: faker.internet.domainWord,
website: faker.internet.url,
base64PhotoData: null,
// ensures creation of associated records if they were not otherwise specified
afterCreate(user, server) {
if (!user.sluggedRoute) {
user.sluggedRoute = server.create('slugged-route', { slug: user.username, user });
user.save();
}
}
});
import Mirage, { faker } from 'ember-cli-mirage';
export default Mirage.Factory.extend({
name: faker.company.bsNoun(),
zip_code: '123456',
email: faker.internet.email(),
is_created: true,
expired_at: faker.date.past(),
color: faker.internet.color(),
description: faker.lorem.sentences(10),
avatar_ids: function() {
return [1, 2];
},
});
let generateSecret = function generateSecret() {
return faker.internet.password(12, false, /[a-f0-9]/);
};
let generateCode = function generateCode() {
return faker.internet.password(32, false, /[a-zA-Z0-9]/);
};
import Mirage, { faker } from 'ember-cli-mirage';
export default Mirage.Factory.extend({
name: faker.company.bsNoun(),
zip_code: '123456',
email: faker.internet.email(),
is_created: true,
expired_at: faker.date.past(),
color: faker.internet.color(),
description: faker.lorem.sentences(10),
avatar_ids: function() {
return [1, 2];
},
});
export function createDeveloperApp(this: HandlerContext, schema: Schema) {
const attrs = {
...this.normalizedRequestAttrs('developer-app'),
clientId: faker.internet.ip(),
clientSecret: faker.random.uuid(),
};
return schema.developerApps.create(attrs);
}
import { Factory, faker } from 'ember-cli-mirage';
import DeveloperApp from 'ember-osf-web/models/developer-app';
export default Factory.extend({
id(i: number) {
return i.toString().padStart(5, '0');
},
name() {
return faker.lorem.words(4);
},
description: faker.lorem.sentence,
homeUrl: faker.internet.url,
callbackUrl() {
return `https://${faker.internet.domainName()}`;
},
clientId() {
return faker.internet.ip();
},
clientSecret() {
return faker.random.uuid();
},
});
declare module 'ember-cli-mirage/types/registries/schema' {
export default interface MirageSchemaRegistry {
developerApps: DeveloperApp;
repository() {
return faker.internet.url();
},
todo() {
import { PurgePolicy } from 'wherehows-web/constants';
import { hdfsUrn, nonHdfsUrn } from 'wherehows-web/mirage/fixtures/urn';
export default Factory.extend({
datasetId: null,
datasetUrn: faker.list.random(hdfsUrn, nonHdfsUrn),
purgeType: faker.list.random(...Object.values(PurgePolicy)),
purgeNote() {
const { purgeType } = this;
return purgeType === PurgePolicy.PurgeExempt ? faker.lorem.words(5) : '';
},
modifiedBy: faker.internet.userName(),
modifiedTime: faker.date.past()
});
infoUrl() {
return faker.internet.url();
},
active: true,