Skip to content

Instantly share code, notes, and snippets.

describe('monkey test', () => {
let userInputs: any[] = [
{budget: 70, apple: 1, pear: 2, orange: 3},
{apple: 3, orange: 1},
{budget: 0}, // <<-- causes change detection exception
{pear: 10}
];
beforeEach(() => {
@jepetko
jepetko / auth-test-skeletton.ts
Last active March 15, 2019 13:53
FeathersJS Authentication test skeletton
describe('POST /users', () => {
describe('for correct user/password data', () => {
let notifierSpy: sinon.SinonSpy;
let mailerStub: sinon.SinonStub;
beforeEach(() => {
notifierSpy = sinon.spy(Notifier, 'onNotify');
mailerStub = sinon.stub(app.service('mailer'), 'create');
@jepetko
jepetko / auth-beforeEach.ts
Created March 15, 2019 13:53
FeathersJS Authentication beforeEach
beforeEach(async () => {
const client: Sequelize.Sequelize = app.get('sequelizeClient');
const models = client.models as {[name: string]: Sequelize.Model<any, any>};
const UserModel = models.users as Sequelize.Model<User, UserAttrs>;
await UserModel.destroy({truncate: true});
setupUserRelatedFactory(UserModel);
});
@jepetko
jepetko / users.factory.ts
Created March 15, 2019 13:58
FeathersJS Authentication User Factory
import * as bcrypt from 'bcryptjs';
const hashPassword = (pwd) => {
const salt = bcrypt.genSaltSync(10);
return bcrypt.hashSync(pwd, salt);
};
export const DEFAULT_PASSWORD = 'pwd';
export function defineUserFactory(factory, model) {
@jepetko
jepetko / get token for Graph API
Last active December 21, 2020 11:51
How to obtain access token for Graph API
import * as qs from 'querystring';
import 'isomorphic-fetch';
import {
AuthenticationHandler,
AuthenticationProviderOptions,
Client,
HTTPMessageHandler
} from '@microsoft/microsoft-graph-client';
export function getClient() {
@jepetko
jepetko / gist:26dfb75bdc5d961681895b9a73a351d2
Last active May 11, 2021 14:25
some_angular_localize_stuff
{
"contact-form--label-lastName": "Numele meu de familie este {$INTERPOLATION} :-)"
}