Justin Dalrymple db63076a5a
Reach > 90% coverage and add Integration Testing (#709)
- Added many many more unit tests to increase coverage to 90% +
- Removed the upsert functionality of PushRules to maintain documented API parity
2020-06-20 14:55:12 +02:00

54 lines
1.4 KiB
TypeScript

import * as FormData from 'form-data';
import { bundler, appendFormFromObject } from '../../../src/infrastructure';
describe('bundler', () => {
/* eslint max-classes-per-file: 0 */
class Test1 {
public value: number;
constructor(value: number) {
this.value = value * 3;
}
}
class Test2 {
public value: number;
constructor(value: number) {
this.value = value * 2;
}
}
it('should merge classes passed to Bundler', async () => {
const Bundle = bundler({ Test1, Test2 });
const services = new Bundle();
expect(services.Test1).toBeInstanceOf(Test1);
expect(services.Test2).toBeInstanceOf(Test2);
});
it('should initialize classes passed to Bundler with options', async () => {
const Bundle = bundler({ Test1, Test2 });
const services = new Bundle(2);
expect(services.Test1.value).toBe(6);
expect(services.Test2.value).toBe(4);
});
});
describe('appendFormFromObject', () => {
it('should convert object key/values to formdata instance', async () => {
const data = { a: 5, b: 'test' };
const form = appendFormFromObject(data);
expect(form).toBeInstanceOf(FormData);
});
it('should convert object key/values with metadata to formdata instance', async () => {
const data = { a: 5, b: ['test', { filename: 'name.jpg' }] };
const form = appendFormFromObject(data);
expect(form).toBeInstanceOf(FormData);
});
});