Skip to content

Commit

Permalink
update dependencies and update test ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuele Tonello committed Nov 12, 2021
1 parent 981c30c commit c499545
Show file tree
Hide file tree
Showing 4 changed files with 4,477 additions and 6,016 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
statements: 96,
branches: 90,
functions: 100,
lines: 96
}
}
lines: 96,
},
},
};
66 changes: 33 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,41 @@
],
"dependencies": {},
"devDependencies": {
"@babel/core": "7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/preset-env": "7.8.7",
"@babel/preset-typescript": "^7.8.3",
"@hapi/joi": "^16.1.7",
"@types/hapi__joi": "^16.0.1",
"@types/jest": "25.1.4",
"@types/node": "^13.1.0",
"@types/validator": "^10.11.3",
"@types/webpack": "^4.4.27",
"@types/webpack-bundle-analyzer": "^2.13.3",
"babel-loader": "^8.0.5",
"fork-ts-checker-webpack-plugin": "^4.0.1",
"jest": "24.7.1",
"lint-staged": "^10.0.3",
"nodemon": "^2.0.0",
"nodemon-webpack-plugin": "^4.2.2",
"now": "^17.0.0",
"@babel/core": "7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-decorators": "^7.16.0",
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/preset-env": "7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@hapi/joi": "^17.1.1",
"@types/hapi__joi": "^17.1.7",
"@types/jest": "27.0.2",
"@types/node": "^16.11.7",
"@types/validator": "^13.6.6",
"@types/webpack": "^5.28.0",
"@types/webpack-bundle-analyzer": "^4.4.1",
"babel-loader": "^8.2.3",
"fork-ts-checker-webpack-plugin": "^6.4.0",
"jest": "27.3.1",
"lint-staged": "^11.2.6",
"nodemon": "^2.0.15",
"nodemon-webpack-plugin": "^4.5.2",
"now": "^21.0.1",
"npm-run-all": "^4.1.5",
"prettier": "1.19.1",
"semantic-release": "^17.0.0",
"source-map-loader": "^0.2.4",
"ts-node": "^8.0.3",
"tslint": "^5.15.0",
"prettier": "2.4.1",
"semantic-release": "^18.0.0",
"source-map-loader": "^3.0.0",
"ts-node": "^10.4.0",
"tslint": "^6.1.3",
"tslint-loader": "^3.6.0",
"typedoc": "^0.16.0",
"typedoc-plugin-external-module-name": "^3.0.0",
"typedoc-plugin-internal-external": "^2.0.1",
"typescript": "^3.7.2",
"validator": "^11.1.0",
"webpack": "4.42.0",
"webpack-bundle-analyzer": "^3.5.2",
"webpack-cli": "^3.3.0"
"typedoc": "^0.22.8",
"typedoc-plugin-external-module-name": "^4.0.6",
"typedoc-plugin-internal-external": "^2.2.0",
"typescript": "^4.4.4",
"validator": "^13.7.0",
"webpack": "5.64.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.1"
},
"eslintConfig": {
"extends": "xo-space",
Expand Down
72 changes: 36 additions & 36 deletions src/morphism.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('Morphism', () => {
const schema: StrictSchema<Destination, Source> = {
foo: 'bar',
bar: 'bar',
qux: elem => elem.bar,
qux: (elem) => elem.bar,
};
const source = { bar: 'value' };

Expand Down Expand Up @@ -140,21 +140,21 @@ describe('Morphism', () => {
});
});

describe('Plain Objects', function() {
it('should export Morphism function curried function', function() {
describe('Plain Objects', function () {
it('should export Morphism function curried function', function () {
expect(typeof Morphism).toEqual('function');
});

it('should provide a mapper function from the partial application', function() {
it('should provide a mapper function from the partial application', function () {
let fn = Morphism({});
expect(typeof fn).toEqual('function');
});

it('should provide an Object as result when Morphism is applied on an Object', function() {
it('should provide an Object as result when Morphism is applied on an Object', function () {
expect(Morphism({}, {})).toEqual({});
});

it('should throw an exception when trying to access a path from an undefined object', function() {
it('should throw an exception when trying to access a path from an undefined object', function () {
Morphism.setMapper<User, any>(User, {
fieldWillThrow: {
path: 'fieldWillThrow.becauseNotReachable',
Expand All @@ -171,7 +171,7 @@ describe('Morphism', () => {
expect(applyMapping).toThrow();
});

it('should rethrow an exception when applying a function on path throws an error', function() {
it('should rethrow an exception when applying a function on path throws an error', function () {
const err = new TypeError('an internal error');
Morphism.setMapper<User, any>(User, {
fieldWillThrow: {
Expand All @@ -189,12 +189,12 @@ describe('Morphism', () => {
});
});

describe('Collection of Objects', function() {
it('should morph an empty array to an empty array || m({}, []) => []', function() {
describe('Collection of Objects', function () {
it('should morph an empty array to an empty array || m({}, []) => []', function () {
expect(Morphism({}, [])).toEqual([]);
});

it('should morph a collection of objects with a stored function || mapObject([{}]) => [Object{}]', function() {
it('should morph a collection of objects with a stored function || mapObject([{}]) => [Object{}]', function () {
const input = [
{
firstName: 'John',
Expand Down Expand Up @@ -229,30 +229,30 @@ describe('Morphism', () => {
const mapUser = Morphism.register(User, schema);
const results = mapUser(input);
results.forEach((res, index) => {
expect(res).toEqual(jasmine.objectContaining(output[index]));
expect(res).toEqual(expect.objectContaining(output[index]));
});

const mapUser2 = Morphism(schema, null, User);
const results2 = mapUser2(input);

results2.forEach((res, index) => {
expect(res).toEqual(jasmine.objectContaining(output[index]));
expect(res).toEqual(expect.objectContaining(output[index]));
});

const results3 = Morphism.map(User, input);
results3.forEach((res, index) => {
expect(res).toEqual(jasmine.objectContaining(output[index]));
expect(res).toEqual(expect.objectContaining(output[index]));
});

const results4 = input.map(userInput => Morphism.map(User, userInput));
const results4 = input.map((userInput) => Morphism.map(User, userInput));
results4.forEach((res, index) => {
expect(res).toEqual(jasmine.objectContaining(output[index]));
expect(res).toEqual(expect.objectContaining(output[index]));
});
});
});

describe('Mapper Instance', function() {
it('should provide a pure idempotent mapper function from the partial application', function() {
describe('Mapper Instance', function () {
it('should provide a pure idempotent mapper function from the partial application', function () {
let schema = {
user: ['firstName', 'lastName'],
city: 'address.city',
Expand All @@ -273,7 +273,7 @@ describe('Morphism', () => {
});
});

describe('Schema', function() {
describe('Schema', function () {
describe('Action Selector', () => {
it('should accept a selector action in deep nested schema property', () => {
interface Source {
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('Morphism', () => {
},
});
});
it('should compute function on data from specified path', function() {
it('should compute function on data from specified path', function () {
let schema = {
state: {
path: 'address.state',
Expand Down Expand Up @@ -370,7 +370,7 @@ describe('Morphism', () => {
interface Target {
t1: string;
}
const schema = createSchema<Target>({ t1: { fn: value => value.s1 } });
const schema = createSchema<Target>({ t1: { fn: (value) => value.s1 } });
const result = morphism(schema, { s1: 'value' });
expect(result.t1).toEqual('value');
});
Expand All @@ -380,7 +380,7 @@ describe('Morphism', () => {
t1: string;
}
const schema = createSchema<Target>({
t1: { fn: value => value.s1, validation: Validation.string() },
t1: { fn: (value) => value.s1, validation: Validation.string() },
});
const result = morphism(schema, { s1: 1234 });
const errors = reporter.report(result);
Expand All @@ -404,8 +404,8 @@ describe('Morphism', () => {
}).toThrow(`The action specified for prop is not supported.`);
});
});
describe('Function Predicate', function() {
it('should support es6 destructuring as function predicate', function() {
describe('Function Predicate', function () {
it('should support es6 destructuring as function predicate', function () {
let schema = {
target: ({ source }: { source: string }) => source,
};
Expand All @@ -421,7 +421,7 @@ describe('Morphism', () => {
expect(result.target.replace).toBeDefined();
});

it('should support nesting mapping', function() {
it('should support nesting mapping', function () {
let nestedSchema = {
target1: 'source',
target2: ({ nestedSource }: any) => nestedSource.source,
Expand All @@ -447,7 +447,7 @@ describe('Morphism', () => {
expect(result).toEqual(expected);
});

it('should be resilient when doing nesting mapping and using destructuration on array', function() {
it('should be resilient when doing nesting mapping and using destructuration on array', function () {
let nestedSchema = {
target: 'source',
nestedTargets: ({ nestedSources }: any) => Morphism({ nestedTarget: ({ nestedSource }: any) => nestedSource }, nestedSources),
Expand Down Expand Up @@ -572,8 +572,8 @@ describe('Morphism', () => {
}
const schema = createSchema<Target, Source>(
{
t1: { fn: value => value.s1, validation: Validation.string() },
t2: { fn: value => value.s1, validation: Validation.string() },
t1: { fn: (value) => value.s1, validation: Validation.string() },
t2: { fn: (value) => value.s1, validation: Validation.string() },
},
{ validation: { throw: true } }
);
Expand Down Expand Up @@ -602,8 +602,8 @@ describe('Morphism', () => {
});
});

describe('Paths Aggregation', function() {
it('should return a object of aggregated values given a array of paths', function() {
describe('Paths Aggregation', function () {
it('should return a object of aggregated values given a array of paths', function () {
let schema = {
user: ['firstName', 'lastName'],
};
Expand All @@ -618,7 +618,7 @@ describe('Morphism', () => {
expect(results[0]).toEqual(desiredResult);
});

it('should return a object of aggregated values given a array of paths (nested path case)', function() {
it('should return a object of aggregated values given a array of paths (nested path case)', function () {
let schema = {
user: ['firstName', 'address.city'],
};
Expand Down Expand Up @@ -652,8 +652,8 @@ describe('Morphism', () => {
});
});

describe('Flattening and Projection', function() {
it('should flatten data from specified path', function() {
describe('Flattening and Projection', function () {
it('should flatten data from specified path', function () {
interface Source {
firstName: string;
lastName: string;
Expand All @@ -679,7 +679,7 @@ describe('Morphism', () => {
expect(results[0]).toEqual(desiredResult);
});

it('should pass the object value to the function when no path is specified', function() {
it('should pass the object value to the function when no path is specified', function () {
interface D {
firstName: string;
lastName: string;
Expand All @@ -690,8 +690,8 @@ describe('Morphism', () => {
let schema: StrictSchema<D, MockData> = {
firstName: 'firstName',
lastName: 'lastName',
city: { path: 'address.city', fn: prop => prop },
status: o => o.phoneNumber[0].type,
city: { path: 'address.city', fn: (prop) => prop },
status: (o) => o.phoneNumber[0].type,
};

let desiredResult = {
Expand All @@ -717,7 +717,7 @@ describe('Morphism', () => {
}

const schema: StrictSchema<Target, Source> = {
keyA: { keyA1: source => source.keyA },
keyA: { keyA1: (source) => source.keyA },
};

const target = morphism(schema, sample);
Expand Down
Loading

0 comments on commit c499545

Please sign in to comment.