Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should handle request without custom headers", () => {
// Arrange
const name = faker.random.word();
const requestOptions: WardenRequestOptions = {
url: faker.internet.url(),
method: 'get'
};
const routeConfiguration = {
identifier: faker.random.word()
} as RouteConfiguration;
const headStream = {
connect: sandbox.stub().returnsArg(0),
start: sandbox.stub()
};
const networkStream = {
connect: sandbox.stub().returnsArg(0)
};
const key = faker.random.word();
const keyMaker = sandbox.stub().returns(key);
streamFactoryMock.expects('createHead').withExactArgs().returns(headStream);
streamFactoryMock.expects('createNetwork').withExactArgs(name).returns(networkStream);
it('should call next and dispatch notification ', () => {
const newInvoice = {
recipient: {
fullname: faker.name.findName(),
email: faker.internet.email(),
},
currency: {
code: 'USD',
placement: 'before',
fraction: 2,
separator: 'commaDot',
},
rows: [
{
id: uuidv4(),
description: faker.commerce.productName(),
price: faker.commerce.price(),
quantity: faker.random.number(10),
},
],
};
// Execute
const action = Actions.saveInvoice(newInvoice);
middleware(action).then(() =>
saveDoc('invoices', newInvoice).then(data => {
// Call next after the promised is returned
expect(next.mock.calls.length).toBe(1);
expect(next).toHaveBeenCalledWith(
Object.assign({}, action, {
payload: [
...mockData.invoicesRecords,
it('Edits profile', () => {
cy.login('admin@admin.com')
cy.setLocaleToEN()
cy.visit('/profile')
const name = `${faker.name.firstName()} ${faker.name.lastName()}`
const phone = faker.phone.phoneNumber()
const country = faker.random.word()
const urlTwitter = faker.internet.url()
const urlGitHub = faker.internet.url()
// name
cy.get('input[name=name]')
.clear()
.type(name)
// phone
cy.get('input[name=phone]')
.clear()
.type(phone)
// city
cy.get('i.mdi-close')
.should('have.class', 'mdi-close')
.click()
cy.get('i.mdi-menu-down')
// -----------------------------------------------------------------------------
// CREATE A FAKE DATA
const faker = require('faker')
const Chance = require('chance')
const chance = new Chance()
let account = {}
account.first = faker.name.firstName()
account.last = faker.name.lastName()
account.name = `${account.first} ${account.last}`
account.username = account.first.toLowerCase()
account.email = `${account.username.toLowerCase()}@${account.last.toLowerCase()}.com`
account.password = faker.internet.password()
account.birthDate = chance.birthday({type: 'adult'})
account.image = faker.image.imageUrl()
account.roles = 'user'
// -----------------------------------------------------------------------------
describe('auth', () => {
// ---------------------------------------------------------------------------
describe('accounts preparation', () => {
it('should able to delete all accounts via /accounts/actions/delete', (done) => {
chai
.request(server)
.delete(`${endpoint}/actions/delete`)
.set('X-API-Key', process.env.API_KEY_SETUP)
.then(res => {
expect(res.body).to.be.an('object')
done()
beforeEach(function () {
const currentTest = this.currentTest;
try {
// we want snapshot tests to use the same random data between runs
const faker = require("faker");
let seed = 0;
for (let i = 0; i < currentTest.fullTitle().length; ++i)
seed += currentTest.fullTitle().charCodeAt(i);
faker.seed(seed);
} catch (e) {
// may throw if package doesn't use faker - ignore
}
// set up snapshot name
const sourceFilePath = currentTest.file.replace("lib\\test", "src\\test").replace(/\.(jsx?|tsx?)$/, "");
const snapPath = sourceFilePath + ".snap";
chaiJestSnapshot.setFilename(snapPath);
chaiJestSnapshot.setTestName(currentTest.fullTitle());
chai.spy.restore();
});
await token.mint(accounts[0], denormalizeBalance(100), {from: accounts[0]});
console.log('Mining tokens 2');
await token.mint(accounts[1], denormalizeBalance(200), {from: accounts[0]});
console.log('Mining tokens 3');
await token.mint(accounts[2], denormalizeBalance(300), {from: accounts[0]});
for(let i = 0; i < 9; i++) {
console.log('Generating event ' + i);
const category = faker.random.arrayElement([1, 2, 3]);
const locale = faker.random.arrayElement(['en'/*, 'ru', 'kz'*/]);
const startDate = Math.floor((new Date()).getTime() / 1000) + 1260; // parseInt(faker.date.future(0.1).getTime()/1000);
const endDate = startDate + 10;
const bidType = faker.lorem.words();
const tags = [faker.lorem.word(), faker.lorem.word(), faker.lorem.word()];
const results = [{description: 'result_description_1', coefficient: 0}, {description: 'result_description_2', coefficient: 0}, {description: 'result_description_3', coefficient: 0}];
const deposit = denormalizeBalance(faker.random.number({min: 10, max: 100}));
const bytes = serializeEvent({
name: faker.lorem.sentence(), // name
description: faker.lorem.sentence(), // description
deposit: deposit, // deposit
bidType: bidType,
category: category,
locale: locale,
startDate: startDate,
endDate: endDate,
sourceUrl: faker.internet.url(), // sourceUrl
tags: tags,
results: results,
return `user${i}`;
},
name: function(i) {
return `User ${i}`;
},
// needs to be the actual related model name for Ember Data reasons? 🤔
type: 'github-user',
avatar_url: function(i) {
return `user${i}-avatar.gif`;
},
public_repos: 1,
public_gists: 2,
followers: 3,
following: 4,
created_at: faker.date.past(),
updated_at: faker.date.recent(),
repos_url: function(i) {
return `https://api.github.com/users/user${i}/repos`;
},
url: function(i) {
return `https://api.github.com/users/user${i}`;
},
withRepositories: trait({
afterCreate(user) {
server.createList('githubRepository', 2, { owner: user });
}
}),
});
// Extract the options from the command line
let argv = yargs
.boolean(`debugPaintRects`)
.default(`debugPaintRects`, false)
.argv;
// Register the segfault handler, just in case
registerHandler();
// Use a static seed so that everybody will get the same output
faker.seed(42);
// Hook the output depending on the command line options
let stdout = undefined;
if (argv.output === undefined) {
stdout = process.stdout;
} else if (argv.output === `encoded`) {
stdout = Object.assign(Object.create(process.stdout), { write: str => console.log(JSON.stringify(str)) });
} else if (argv.output === false) {
stdout = Object.assign(Object.create(process.stdout), { write: str => undefined });
} else {
throw new Error(`Failed to execute: Invalid output '${argv.output}'.`);
}
// Setup the screen
UserModel.belongsToMany(UserModel, { through: 'Friends', as: 'friends' });
// messages are sent from users
MessageModel.belongsTo(UserModel);
// messages are sent to groups
MessageModel.belongsTo(GroupModel);
// groups have multiple users
GroupModel.belongsToMany(UserModel, { through: 'GroupUser' });
// create fake starter data
const GROUPS = 4;
const USERS_PER_GROUP = 5;
const MESSAGES_PER_USER = 5;
faker.seed(123); // get consistent data every time we reload app
// you don't need to stare at this code too hard
// just trust that it fakes a bunch of groups, users, and messages
db.sync({ force: true }).then(() => _.times(GROUPS, () => GroupModel.create({
name: faker.lorem.words(3),
}).then(group => _.times(USERS_PER_GROUP, () => {
const password = faker.internet.password();
return bcrypt.hash(password, 10).then(hash => group.createUser({
email: faker.internet.email(),
username: faker.internet.userName(),
password: hash,
}).then((user) => {
console.log(
'{email, username, password}',
`{${user.email}, ${user.username}, ${password}}`
);
require('./routes/routes.js')(app, passport);
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
var faker = require('faker');
var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
var randomCard = faker.helpers.createCard(); // random contact card containing many properties
console.log(randomName,randomEmail,randomCard);
module.exports = app;