How to use the faker/locale/en_US.random function in faker

To help you get started, we’ve selected a few faker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graycoreio / daffodil / libs / checkout / testing / src / order / factories / order-shipping-rate.factory.ts View on Github external
import { Injectable } from '@angular/core';

import { OrderShippingRate } from '@daffodil/checkout';
import * as faker from 'faker/locale/en_US';
import { DaffModelFactory } from '@daffodil/core/testing';

export class MockOrderShippingRate implements OrderShippingRate {
  rate_id = faker.random.number(1000);
  address_id = faker.random.number(1000);
  created_at = new Date();
  updated_at = new Date();
  carrier = 'Birds Inc.';
  carrier_title = 'laden';
  code = 'code';
  method = 'swallow';
  method_description = 'efficient';
  price = faker.random.number(1000);
  error_message = 'error message';
  method_title = 'laden';
}

@Injectable({
    providedIn: 'root'
})
github graycoreio / daffodil / libs / core / testing / src / cart / factories / cart-shipping-rate.factory.ts View on Github external
import { Injectable } from "@angular/core";

import { CartShippingRate } from "@daffodil/core";
import * as faker from 'faker/locale/en_US';
import { ModelFactory } from "../../factories/factory";

export class MockCartShippingRate implements CartShippingRate {
    rate_id = faker.random.number(1000);
    address_id = faker.random.number(1000);
    created_at = new Date();
    updated_at = new Date();
    carrier = 'Birds Inc.';
    carrier_title = 'laden';
    code = 'code';
    method = 'swallow';
    method_description = 'efficient';
    price = faker.random.number(1500);
    error_message = 'error message';
    method_title = 'laden';
}

@Injectable({
    providedIn: 'root'
})
export class DaffCartShippingRateFactory extends ModelFactory{
github graycoreio / daffodil / libs / category / testing / src / factories / category.factory.ts View on Github external
import { Injectable } from '@angular/core';
import * as faker from 'faker/locale/en_US';

import { DaffCategory } from '@daffodil/category';
import { DaffModelFactory } from '@daffodil/core/testing';

export class MockCategory implements DaffCategory {
  id = faker.random.number(10000).toString();
  name = faker.commerce.productMaterial();
  breadcrumbs = [{
    categoryId: faker.random.number(100),
    categoryName: faker.commerce.productMaterial(),
    categoryLevel: faker.random.number(5),
    categoryUrlKey: faker.commerce.productMaterial()
  }]
  children_count = faker.random.number(10);
  total_products = faker.random.number(10);
  productIds = [faker.random.number(100).toString()];
}

@Injectable({
  providedIn: 'root'
})
export class DaffCategoryFactory extends DaffModelFactory{
  constructor(){
    super(MockCategory);
  }
}
github graycoreio / daffodil / libs / category / testing / src / factories / category.factory.ts View on Github external
import { Injectable } from '@angular/core';
import * as faker from 'faker/locale/en_US';

import { DaffCategory } from '@daffodil/category';
import { DaffModelFactory } from '@daffodil/core/testing';

export class MockCategory implements DaffCategory {
  id = faker.random.number(10000).toString();
  name = faker.commerce.productMaterial();
  breadcrumbs = [{
    categoryId: faker.random.number(100),
    categoryName: faker.commerce.productMaterial(),
    categoryLevel: faker.random.number(5),
    categoryUrlKey: faker.commerce.productMaterial()
  }]
  children_count = faker.random.number(10);
  total_products = faker.random.number(10);
  productIds = [faker.random.number(100).toString()];
}

@Injectable({
  providedIn: 'root'
})
export class DaffCategoryFactory extends DaffModelFactory{
github graycoreio / daffodil / libs / cart / testing / src / factories / cart-address.factory.ts View on Github external
import { Injectable } from '@angular/core';

import { DaffCartAddress } from '@daffodil/cart';
import * as faker from 'faker/locale/en_US';

import { DaffModelFactory } from '@daffodil/core/testing';

export class MockCartAddress implements DaffCartAddress {
  address_id = faker.random.number(1000);
  quote_id = faker.random.number(1000);
  created_at = new Date();
  updated_at = new Date();
  customer_id = faker.random.number(1000);
  customer_address_id = faker.random.number(1000);
  address_type = 'apartment';
  email = 'email@email.com';
  prefix = 'prefix';
  firstname = 'first';
  middlename = 'middle';
  lastname = 'last';
  suffix = 'suffix';
  company = 'company';
  street = 'street';
  city = 'city';
  state = 'state';
  region = 'region';
  region_id = faker.random.number(1000);
  postcode = 'postcode';
  country_id = 'ISO';
  telephone = 'telephone';
github graycoreio / daffodil / libs / checkout / testing / src / shipping / factories / shipping-option.factory.ts View on Github external
import { Injectable } from '@angular/core';

import { ShippingOption } from '@daffodil/checkout';
import { DaffModelFactory } from '@daffodil/core/testing';

import * as faker from 'faker/locale/en_US';

export class MockShippingOption implements ShippingOption {
  id = faker.random.number().toString();
  text = faker.company.companyName() + ' ' + faker.commerce.productAdjective() + ' Shipping'
}

@Injectable({
  providedIn: 'root'
})
export class DaffShippingOptionFactory extends DaffModelFactory{
  constructor(){
    super(MockShippingOption);
  }
}
github graycoreio / daffodil / libs / cart / testing / src / factories / cart-item.factory.ts View on Github external
import { Injectable } from '@angular/core';
import * as faker from 'faker/locale/en_US';

import { DaffCartItem } from '@daffodil/cart';

import { DaffModelFactory } from '@daffodil/core/testing';

export class MockCartItem implements DaffCartItem {
  item_id = faker.random.number(1000);
  image = null;
  quote_id = faker.random.number(1000);
  created_at = new Date();
  updated_at = new Date();
  product_id = faker.random.number(1000);
  parent_item_id = faker.random.number(1000);
  sku = 'sku';
  name = 'Product Name';
  description = 'description';
  weight = faker.random.number(1000);
  qty = faker.random.number({min:1, max:100});
  price = faker.random.number(1500);
  discount_percent = faker.random.number(10);
  discount_amount = faker.random.number(100);
  tax_percent = faker.random.number(10);
  tax_amount = faker.random.number(10);
github graycoreio / daffodil / libs / cart / testing / src / factories / cart-shipping-rate.factory.ts View on Github external
import { Injectable } from '@angular/core';

import { DaffCartShippingRate } from '@daffodil/cart';
import * as faker from 'faker/locale/en_US';
import { DaffModelFactory } from '@daffodil/core/testing';

export class MockCartShippingRate implements DaffCartShippingRate {
    rate_id = faker.random.number(1000);
    address_id = faker.random.number(1000);
    created_at = new Date();
    updated_at = new Date();
    carrier = 'Birds Inc.';
    carrier_title = 'laden';
    code = 'code';
    method = 'swallow';
    method_description = 'efficient';
    price = faker.random.number(1500);
    error_message = 'error message';
    method_title = 'laden';
}

@Injectable({
    providedIn: 'root'
})
github graycoreio / daffodil / libs / checkout / testing / src / order / factories / order-address.factory.ts View on Github external
updated_at = new Date();
  customer_id = faker.random.number(1000);
  customer_address_id = faker.random.number(1000);
  address_type = 'apartment';
  email = 'email@email.com';
  prefix = 'prefix';
  firstname = 'first';
  middlename = 'middle';
  lastname = 'last';
  suffix = 'suffix';
  company = 'company';
  street = 'street';
  city = 'city';
  state = 'state';
  region = 'region';
  region_id = faker.random.number(1000);
  postcode = 'postcode';
  country_id = 'ISO';
  telephone = 'telephone';
  fax = 'fax';
  shipping_method = 'swallow';
  shipping_description = 'flight';
  shipping_rate = null;
}

@Injectable({
  providedIn: 'root'
})
export class DaffOrderAddressFactory extends DaffModelFactory {
  
  constructor(){
    super(MockOrderAddress);
github graycoreio / daffodil / libs / cart / testing / src / factories / cart-address.factory.ts View on Github external
import { Injectable } from '@angular/core';

import { DaffCartAddress } from '@daffodil/cart';
import * as faker from 'faker/locale/en_US';

import { DaffModelFactory } from '@daffodil/core/testing';

export class MockCartAddress implements DaffCartAddress {
  address_id = faker.random.number(1000);
  quote_id = faker.random.number(1000);
  created_at = new Date();
  updated_at = new Date();
  customer_id = faker.random.number(1000);
  customer_address_id = faker.random.number(1000);
  address_type = 'apartment';
  email = 'email@email.com';
  prefix = 'prefix';
  firstname = 'first';
  middlename = 'middle';
  lastname = 'last';
  suffix = 'suffix';
  company = 'company';
  street = 'street';
  city = 'city';
  state = 'state';