ref: remove jest and lastn functions.test.js

It doesn't play well with webpack and it's babel config
and I couldn't find a way to make it work.
This commit is contained in:
paweldomas 2020-08-21 06:46:33 -05:00 committed by Paweł Domas
parent e51bbe6125
commit 6453ceb048
4 changed files with 2 additions and 7394 deletions

View File

@ -1,9 +0,0 @@
module.exports = {
moduleFileExtensions: [
'js'
],
testMatch: [
'<rootDir>/react/**/?(*.)+(test)?(.web).js?(x)'
],
verbose: true
};

7282
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -125,7 +125,6 @@
"expose-loader": "0.7.5", "expose-loader": "0.7.5",
"flow-bin": "0.104.0", "flow-bin": "0.104.0",
"imports-loader": "0.7.1", "imports-loader": "0.7.1",
"jest": "26.1.0",
"jetifier": "1.6.4", "jetifier": "1.6.4",
"metro-react-native-babel-preset": "0.56.0", "metro-react-native-babel-preset": "0.56.0",
"node-sass": "4.14.1", "node-sass": "4.14.1",
@ -145,7 +144,6 @@
"scripts": { "scripts": {
"lint": "eslint . && flow", "lint": "eslint . && flow",
"postinstall": "jetify", "postinstall": "jetify",
"test": "jest",
"validate": "npm ls" "validate": "npm ls"
}, },
"browser": { "browser": {

View File

@ -1,103 +0,0 @@
import { limitLastN, validateLastNLimits } from './functions';
describe('limitLastN', () => {
it('handles undefined mapping', () => {
expect(limitLastN(0, undefined)).toBe(undefined);
});
describe('when a correct limit mapping is given', () => {
const limits = new Map();
limits.set(5, -1);
limits.set(10, 8);
limits.set(20, 5);
it('returns undefined when less participants that the first limit', () => {
expect(limitLastN(2, limits)).toBe(undefined);
});
it('picks the first limit correctly', () => {
expect(limitLastN(5, limits)).toBe(-1);
expect(limitLastN(9, limits)).toBe(-1);
});
it('picks the middle limit correctly', () => {
expect(limitLastN(10, limits)).toBe(8);
expect(limitLastN(13, limits)).toBe(8);
expect(limitLastN(19, limits)).toBe(8);
});
it('picks the top limit correctly', () => {
expect(limitLastN(20, limits)).toBe(5);
expect(limitLastN(23, limits)).toBe(5);
expect(limitLastN(100, limits)).toBe(5);
});
});
});
describe('validateLastNLimits', () => {
describe('validates the input by returning undefined', () => {
it('if lastNLimits param is not an Object', () => {
expect(validateLastNLimits(5)).toBe(undefined);
});
it('if any key is not a number', () => {
const limits = {
'abc': 8,
5: -1,
20: 5
};
expect(validateLastNLimits(limits)).toBe(undefined);
});
it('if any value is not a number', () => {
const limits = {
8: 'something',
5: -1,
20: 5
};
expect(validateLastNLimits(limits)).toBe(undefined);
});
it('if any value is null', () => {
const limits = {
1: 1,
5: null,
20: 5
};
expect(validateLastNLimits(limits)).toBe(undefined);
});
it('if any value is undefined', () => {
const limits = {
1: 1,
5: undefined,
20: 5
};
expect(validateLastNLimits(limits)).toBe(undefined);
});
it('if the map is empty', () => {
expect(validateLastNLimits({})).toBe(undefined);
});
});
it('sorts by the keys', () => {
const mappingKeys = validateLastNLimits({
10: 5,
3: 3,
5: 4
}).keys();
expect(mappingKeys.next().value).toBe(3);
expect(mappingKeys.next().value).toBe(5);
expect(mappingKeys.next().value).toBe(10);
expect(mappingKeys.next().done).toBe(true);
});
it('converts keys and values to numbers', () => {
const mapping = validateLastNLimits({
3: 3,
5: 4,
10: 5
});
for (const key of mapping.keys()) {
expect(typeof key).toBe('number');
expect(typeof mapping.get(key)).toBe('number');
}
});
});