first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
import { findMatches, removeIgnored } from '../../v2/helpers/utils';
|
||||
|
||||
describe('test AirtableV2, removeIgnored', () => {
|
||||
it('should remove ignored fields', () => {
|
||||
const data = {
|
||||
foo: 'foo',
|
||||
baz: 'baz',
|
||||
spam: 'spam',
|
||||
};
|
||||
|
||||
const ignore = 'baz,spam';
|
||||
|
||||
const result = removeIgnored(data, ignore);
|
||||
|
||||
expect(result).toEqual({
|
||||
foo: 'foo',
|
||||
});
|
||||
});
|
||||
it('should return the same data if ignore field does not present', () => {
|
||||
const data = {
|
||||
foo: 'foo',
|
||||
};
|
||||
|
||||
const ignore = 'bar';
|
||||
|
||||
const result = removeIgnored(data, ignore);
|
||||
|
||||
expect(result).toEqual(data);
|
||||
});
|
||||
it('should return the same data if empty string', () => {
|
||||
const data = {
|
||||
foo: 'foo',
|
||||
};
|
||||
|
||||
const ignore = '';
|
||||
|
||||
const result = removeIgnored(data, ignore);
|
||||
|
||||
expect(result).toEqual(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('test AirtableV2, findMatches', () => {
|
||||
it('should find match', () => {
|
||||
const data = [
|
||||
{
|
||||
fields: {
|
||||
id: 'rec123',
|
||||
data: 'data 1',
|
||||
},
|
||||
},
|
||||
{
|
||||
fields: {
|
||||
id: 'rec456',
|
||||
data: 'data 2',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const key = 'id';
|
||||
|
||||
const result = findMatches(data, [key], {
|
||||
id: 'rec123',
|
||||
data: 'data 1',
|
||||
});
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
fields: {
|
||||
id: 'rec123',
|
||||
data: 'data 1',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
it('should find all matches', () => {
|
||||
const data = [
|
||||
{
|
||||
fields: {
|
||||
id: 'rec123',
|
||||
data: 'data 1',
|
||||
},
|
||||
},
|
||||
{
|
||||
fields: {
|
||||
id: 'rec456',
|
||||
data: 'data 2',
|
||||
},
|
||||
},
|
||||
{
|
||||
fields: {
|
||||
id: 'rec123',
|
||||
data: 'data 3',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const key = 'id';
|
||||
|
||||
const result = findMatches(
|
||||
data,
|
||||
[key],
|
||||
{
|
||||
id: 'rec123',
|
||||
data: 'data 1',
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
fields: {
|
||||
id: 'rec123',
|
||||
data: 'data 1',
|
||||
},
|
||||
},
|
||||
{
|
||||
fields: {
|
||||
id: 'rec123',
|
||||
data: 'data 3',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user