Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import 'babel-polyfill';
import chai from 'chai';
import Chance from 'chance';
import _ from 'lodash';
import { findGroups, decompose345, findDecomposition } from '../src/helpers';
import type { User } from '../src/db';
const chance = new Chance();
function forgeUser(uniqueid: string, lang: string): User {
return {
lang,
slug: chance.word(),
firstname: chance.first(),
name: chance.last(),
uniqueid,
email: chance.email(),
lastSeen: chance.date().toISOString(),
};
}
const should = chai.should();
describe('Match making', () => {
import React from 'react'
import {storiesOf, action} from 'part:@sanity/storybook'
import Autocomplete from 'part:@sanity/components/autocomplete/default'
import {range} from 'lodash'
import Chance from 'chance'
const chance = new Chance()
const formStyle = {width: '30em', margin: '0 auto', paddingBottom: '20em'}
storiesOf('Autocomplete')
.add(
'Default',
// `
// Autocomplete is used to help user complete a normal text input. The input can be anything.
// `,
() => {
return (
<form style="{formStyle}">
</form>
* 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 expect from 'expect.js';
import Chance from 'chance';
const chance = new Chance();
import {
KbnFieldType,
getKbnFieldType,
castEsToKbnFieldTypeName,
getKbnTypeNames
} from '../kbn_field_types';
describe('utils/kbn_field_types', () => {
describe('KbnFieldType', () => {
it('defaults', () => {
expect(new KbnFieldType())
.to.have.property('name', undefined)
.and.have.property('sortable', false)
.and.have.property('filterable', false)
.and.have.property('esTypes').eql([]);
});
import Chance from 'chance';
import * as actions from '../../../../src/frontend/actions/index';
const chance = new Chance();
describe('todo action tests', () => {
test('createTodo should create ADD_TODO action', () => {
const text = chance.sentence();
expect(actions.createTodo({ text })).toEqual({
todo: { text },
type: 'ADD_TODO',
});
});
test('deleteTodo should create DELETE_TODO action', () => {
const id = chance.string();
expect(actions.deleteTodo(id)).toEqual({
id,
/*eslint-ignore*/
import Chance from 'chance';
import core from 'coreApi';
import { expectCollectionsToBeEqual, expectToHaveSameMembers } from '../utils/helpers';
import { TaskModel, addChanceMixins } from '../utils/testData';
const chance = new Chance();
const repository = addChanceMixins(chance);
describe('VirtualCollection', () => {
const assigneeGrouping = {
modelFactory(model) {
return model.get('assignee');
},
comparator(model) {
return model.get('assignee').id;
},
iterator(model) {
return model.get('assignee').get('name');
},
affectedAttributes: ['assignee']
};
import { expect } from 'chai';
import Chance from 'chance';
import builder from './createIsoConfig';
const chance = new Chance();
const fakeAssetsName = chance.file();
const assetPath = `${chance.word()}/${chance.word()}`;
const subject = builder({
path: require('path')
});
describe('create iso config', () => {
it('return json with a path matching the components dir', () => {
const config = subject(assetPath, fakeAssetsName);
expect(config.webpack_assets_file_path.endsWith(`${assetPath}/${fakeAssetsName}`)).to.equal(true);
});
});
import Chance from 'chance';
const chance = new Chance();
export default class NumberParser {
canParse(node) {
return this.isInteger(node) || this.isFloating(node);
}
parse(node) {
if (this.isInteger(node))
return this.generateInteger(node);
if (this.isFloating(node))
return chance.floating(node['x-type-options']);
}
generateInteger(node) {
let bounds = this.resolveBounds(node);
configure(() => {
global.Globalize = Globalize;
let chance = global.chance = new Chance();
global.generateNames = function(limit = 100) {
var arr = new Array(limit)
for(var i = 0; i < arr.length; i++){
var first = chance.first()
, last = chance.last()
arr[i] = {
first,
last,
id: i + 1,
fullName: `${first} ${last}`,
}
}
parentEntity,
name = generateStationName(),
hideOccAndSit = false,
generate = true,
isHidden,
} = {}) => {
if (!sector) {
throw new Error('Sector must be defined to generate a moon base');
}
if (!parent || !parentEntity) {
throw new Error(
'Parent id and type must be defined to generate a moon base',
);
}
const chance = new Chance();
let asteroidBase = { name, parent, parentEntity, sector };
if (isHidden !== undefined) {
asteroidBase = { ...asteroidBase, isHidden };
}
if (generate) {
if (hideOccAndSit) {
asteroidBase.visibility = {
'attr.occupation': false,
'attr.situation': false,
};
}
asteroidBase = {
...asteroidBase,
attributes: {
occupation: chance.pickone(Object.keys(Occupation.attributes)),
situation: chance.pickone(Object.keys(Situation.attributes)),
import Chance from 'chance'
const chance = new Chance()
function getRandomProfile (_profile = {}) {
return Object.assign(_profile, {
hash: chance.hash({length: 15}),
username: chance.sentence({words: 2}),
date: chance.date()
})
}
export class ProfileMock {
get () {
return Promise.resolve(getRandomProfile())
}
}
const instance = new ProfileMock()