Skip to content

Commit

Permalink
fix: Add additional operator tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gervwyk committed Jul 20, 2022
1 parent d6a25ef commit ddf8e51
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
Expand Up @@ -41,4 +41,16 @@ test('url_query calls getFromObject', async () => {
},
],
]);
expect(() =>
expect(
url_query({
arrayIndices: [0],
globals: {},
location: 'location',
params: 'params',
})
)
).toThrowErrorMatchingInlineSnapshot(
`"Operator Error: Browser window.location not available for _url_query. Received: \\"params\\" at location."`
);
});
Expand Up @@ -167,6 +167,13 @@ describe('_array.every', () => {
parser,
});
test('valid', () => {
expect(
_array({
params: [null, callback],
methodName,
location,
})
).toEqual(true);
expect(
_array({
params: {
Expand Down Expand Up @@ -317,6 +324,13 @@ describe('_array.filter', () => {
parser,
});
test('valid', () => {
expect(
_array({
params: [null, callback],
methodName,
location,
})
).toEqual([]);
expect(
_array({
params: {
Expand Down Expand Up @@ -384,6 +398,13 @@ describe('_array.find', () => {
parser,
});
test('valid', () => {
expect(
_array({
params: [null, callback],
methodName,
location,
})
).toEqual(undefined);
expect(
_array({
params: {
Expand Down Expand Up @@ -451,6 +472,13 @@ describe('_array.findIndex', () => {
parser,
});
test('valid', () => {
expect(
_array({
params: [null, callback],
methodName,
location,
})
).toEqual(-1);
expect(
_array({
params: {
Expand Down Expand Up @@ -512,6 +540,13 @@ describe('_array.findIndex', () => {
describe('_array.flat', () => {
const methodName = 'flat';
test('valid', () => {
expect(
_array({
params: [null],
methodName,
location,
})
).toEqual([]);
expect(
_array({
params: [[1, 2, [3], [[4]]]],
Expand Down Expand Up @@ -568,6 +603,13 @@ describe('_array.flat', () => {
describe('_array.includes', () => {
const methodName = 'includes';
test('valid', () => {
expect(
_array({
params: [null, 1],
methodName,
location,
})
).toEqual(false);
expect(
_array({
params: [[1, 2, 3], 2],
Expand Down Expand Up @@ -631,6 +673,13 @@ describe('_array.includes', () => {
describe('_array.indexOf', () => {
const methodName = 'indexOf';
test('valid', () => {
expect(
_array({
params: [null, 1],
methodName,
location,
})
).toEqual(-1);
expect(
_array({
params: [[1, 2, 3], 2],
Expand Down Expand Up @@ -694,6 +743,13 @@ describe('_array.indexOf', () => {
describe('_array.join', () => {
const methodName = 'join';
test('valid', () => {
expect(
_array({
params: [null, '-'],
methodName,
location,
})
).toEqual('');
expect(
_array({
params: [[1, 2, 3], '-'],
Expand Down Expand Up @@ -750,6 +806,13 @@ describe('_array.join', () => {
describe('_array.lastIndexOf', () => {
const methodName = 'lastIndexOf';
test('valid', () => {
expect(
_array({
params: [null, 1],
methodName,
location,
})
).toEqual(-1);
expect(
_array({
params: [[1, 2, 3, 2], 2],
Expand Down Expand Up @@ -812,6 +875,13 @@ describe('_array.map', () => {
parser,
});
test('valid', () => {
expect(
_array({
params: [null, callback],
methodName,
location,
})
).toEqual([]);
expect(
_array({
params: {
Expand Down Expand Up @@ -934,6 +1004,15 @@ describe('_array.reduce', () => {
).toEqual(8);
});
test('throw', () => {
expect(() =>
_array({
params: [null, callback],
methodName,
location,
})
).toThrowErrorMatchingInlineSnapshot(
`"Operator Error: _array.reduce - Reduce of empty array with no initial value Received: {\\"_array.reduce\\":[null,null]} at location."`
);
expect(() =>
_array({
params: { on: 0 },
Expand Down Expand Up @@ -1016,6 +1095,17 @@ describe('_array.reduceRight', () => {
).toEqual(0);
});
test('throw', () => {
expect(() =>
expect(
_array({
params: [null, callback],
methodName,
location,
})
)
).toThrowErrorMatchingInlineSnapshot(
`"Operator Error: _array.reduceRight - Reduce of empty array with no initial value Received: {\\"_array.reduceRight\\":[null,null]} at location."`
);
expect(() =>
_array({
params: { on: 0 },
Expand Down Expand Up @@ -1093,6 +1183,13 @@ describe('_array.reverse', () => {
describe('_array.slice', () => {
const methodName = 'slice';
test('valid', () => {
expect(
_array({
params: [null, 1, 2],
methodName,
location,
})
).toEqual([]);
expect(
_array({
params: [[1, 2, 3, 4, 5], 1, 3],
Expand Down Expand Up @@ -1149,6 +1246,13 @@ describe('_array.slice', () => {
describe('_array.splice', () => {
const methodName = 'splice';
test('valid', () => {
expect(
_array({
params: [null, 1, 0],
methodName,
location,
})
).toEqual([]);
expect(
_array({
params: [['b', 'c', 'a'], 1, 0, 1, 2, 3],
Expand Down Expand Up @@ -1214,6 +1318,13 @@ describe('_array.some', () => {
parser,
});
test('valid', () => {
expect(
_array({
params: [null, callback],
methodName,
location,
})
).toEqual(false);
expect(
_array({
params: {
Expand Down Expand Up @@ -1289,6 +1400,13 @@ describe('_array.some', () => {
describe('_array.sort', () => {
const methodName = 'sort';
test('valid', () => {
expect(
_array({
params: [null],
methodName,
location,
})
).toEqual([]);
expect(
_array({
params: [[4, 1, 2, 3]],
Expand Down Expand Up @@ -1355,6 +1473,13 @@ describe('_array.sort', () => {
describe('_array.length', () => {
const methodName = 'length';
test('valid', () => {
expect(
_array({
params: null,
methodName,
location,
})
).toEqual(0);
expect(
_array({
params: [[1, 2, 3], 2],
Expand Down

0 comments on commit ddf8e51

Please sign in to comment.