Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Tables
db.posts = []
db.comments = []
db.albums = []
db.photos = []
db.users = []
db.todos = []
// Factories
Factory.define('post')
.sequence('id')
.attr('title', function() {return Faker.Lorem.sentence()})
.attr('body', function() {return Faker.Lorem.sentences(4)})
Factory.define('comment')
.sequence('id')
.attr('name', function() {return Faker.Lorem.sentence()})
.attr('email', function() {return Faker.Internet.email()})
.attr('body', function() {return Faker.Lorem.sentences(4)})
Factory.define('album')
.sequence('id')
.attr('title', function() {return Faker.Lorem.sentence()})
Factory.define('photo')
.sequence('id')
.attr('title', function() {return Faker.Lorem.sentence()})
.option('color', hex())
.attr('url', [ 'color' ], function(color) {
return 'http://placehold.it/600/' + color
})
Factory.define('album')
.sequence('id')
.attr('title', function() {return Faker.Lorem.sentence()})
Factory.define('photo')
.sequence('id')
.attr('title', function() {return Faker.Lorem.sentence()})
.option('color', hex())
.attr('url', [ 'color' ], function(color) {
return 'http://placehold.it/600/' + color
})
.attr('thumbnailUrl', [ 'color' ], function(color) {
return 'http://placehold.it/150/' + color
})
Factory.define('todo')
.sequence('id')
.attr('title', function() {return Faker.Lorem.sentence()})
.attr('completed', function() { return _.random(1) ? true : false})
Factory.define('user')
.sequence('id')
.after(function(user) {
var card = Faker.Helpers.userCard()
_.each(card, function(value, key) {
user[key] = value
})
})
// Has many relationships
// Users
_(10).times(function () {
.option('inMerge', false)
.option('isCollaborator', true)
.option('isArchived', false)
.option('isReadOnlyMode', ['isCertified', 'inMerge', 'isCollaborator', 'isArchived'], (isCertified, inMerge, isCollaborator, isArchived) =>
isCertified || inMerge || !isCollaborator
)
.attr('itemPermission', ['isCertified', 'inMerge', 'isCollaborator'], (isCertified, inMerge, isCollaborator) =>
InitializedItemPermissionFactory.build({isCollaborator, isCertified, inMerge})
)
.attr('props', ['isReadOnlyMode'], (isReadOnlyMode) => {
return {isReadOnlyMode};
});
export const InitializedCurrentScreenFactory = new Factory().extend('InitializedCurrentScreenFactory');
Factory.define('CurrentScreenFactory')
.extend('InitializedCurrentScreenFactory')
.option('isDirty', false)
.option('isOutOfSync', false)
.option('isUpToDate', true)
.option('version', ['isCertified'], (isCertified) => VersionFactory.build({isCertified}))
.attr('itemPermission', [
'isCertified', 'inMerge', 'isCollaborator', 'isDirty', 'isOutOfSync', 'isUpToDate', 'isArchived'
], (isCertified, inMerge, isCollaborator, isDirty, isOutOfSync, isUpToDate, isArchived) =>
ItemPermissionFactory.build({isCollaborator, isCertified, inMerge, isDirty, isOutOfSync, isUpToDate, isArchived})
)
.attr('props', ['isReadOnlyMode', 'version'], (isReadOnlyMode, version) => {
return {isReadOnlyMode, version};
});
export default new Factory().extend('CurrentScreenFactory');
import { Factory } from "rosie";
import stellar from "stellar-base";
import { Signer } from "../../src/model/signer";
Factory.define("signer")
.attr("accountID", () => stellar.Keypair.random().publicKey())
.attr("signer", () => stellar.Keypair.random().publicKey())
.attr("weight", () => Math.floor(Math.random() * 5));
export default {
build(overrides?: object): Signer {
const data = Factory.attributes("signer", overrides);
return new Signer(data);
}
};
import { BigNumber } from "bignumber.js";
import { Factory } from "rosie";
import stellar from "stellar-base";
import { Account } from "../../src/orm/entities";
Factory.define("account")
.attr("id", () => stellar.Keypair.random().publicKey())
.attr("balance", "19729999500")
.attr("sequenceNumber", "12884901893")
.attr("numSubentries", 1)
.attr("inflationDest", "")
.attr("homeDomain", "")
.attr("thresholds", "AQAAAA==")
.attr("flags", 0)
.attr("lastModified", 6)
.attr("sellingLiabilities", new BigNumber("8927364"))
.attr("buyingLiabilities", new BigNumber("2948361"));
export default {
build(overrides?: object): Account {
const data = Factory.attributes("account", overrides);
const account = new Account();
import { Factory } from "rosie";
import stellar from "stellar-base";
import { AccountFlags, AccountThresholds, AccountValues, IAccountFlags } from "../../src/model";
Factory.define("account_values")
.attr("id", () => stellar.Keypair.random().publicKey())
.attr("balance", "19729999500")
.attr("sequenceNumber", "12884901893")
.attr("numSubentries", 1)
.attr("inflationDestination", "")
.attr("homeDomain", "")
.attr("thresholds", new AccountThresholds({ masterWeight: 1, low: 1, medium: 1, high: 1 }))
.attr("flags", new AccountFlags({ authRequired: false, authImmutable: false, authRevocable: false }))
.attr("lastModified", 6)
.attr("signers", []);
export default {
build(overrides?: any): AccountValues {
const data = Factory.attributes("account_values", overrides);
data.signers = (overrides && overrides.signers) || [];
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import {Factory} from 'rosie';
import IdMixin from 'test-utils/factories/mixins/IdMixin.js';
import randomstring from 'randomstring';
Factory.define('VSPBaseFactory')
.attrs(
{
name: 'VSP2',
description: 'sdsd',
category: 'resourceNewCategory.application l4+',
subCategory: 'resourceNewCategory.application l4+.media servers',
vendorName: 'V1 ',
vendorId: () => randomstring.generate(33),
licensingVersion: {id: '1', label: '1'},
licensingData: {},
icon: 'icon',
version: '123'
}
);
Factory.define('LicensingDataMixin')
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import { Factory } from 'rosie';
import { overviewEditorHeaders } from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
Factory.define('EntitlementPoolBaseFactory').attrs({
name: 'EntitlementPoolName',
description: 'description'
});
Factory.define('EntitlementPoolExtendedBaseFactory')
.extend('EntitlementPoolBaseFactory')
.attrs({
manufacturerReferenceNumber: '1231322',
thresholdValue: 76,
thresholdUnits: '%',
increments: 'string',
startDate: new Date().getTime(),
expiryDate: new Date().getTime()
});
export const EntitlementPoolListItemFactory = new Factory()
class FirebaseError extends Error {
constructor(args) {
super(args.name);
this.code = args.name;
this.credential = args.credential;
Error.captureStackTrace(this, FirebaseError);
}
}
export const credentialFactory = new Factory().attrs({
providerId: 'github.com',
accessToken: 'abc123',
});
export const firebaseErrorFactory = Factory.define(
'firebaseError',
FirebaseError,
).attrs({
name: 'some other error',
});
export const credentialInUseErrorFactory = new Factory()
.extend(firebaseErrorFactory)
.attrs({
name: 'auth/credential-already-in-use',
credential: () => credentialFactory.build(),
});
export const userProviderDataFactory = new Factory().attrs({
displayName: 'popcoder',
email: null,
amount: faker.finance.amount(1, 100, 0),
data: Buffer.alloc(0),
destination: 'test.rafiki.' + faker.name.firstName(),
expiresAt: new Date(Date.now() + 10 * 1000),
executionCondition: STATIC_CONDITION
}
)
export const IlpFulfillFactory = Factory.define('IlpFulFill').attrs(
{
fulfillment: STATIC_FULFILLMENT,
data: Buffer.alloc(0)
}
)
export const IlpRejectFactory = Factory.define('IlpReject').attrs({
triggeredBy: 'test.rafiki.' + faker.name.firstName(),
code: 'F02',
message: 'Peer unreachable',
data: Buffer.alloc(0)
})