Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manelcecs committed Nov 20, 2024
1 parent f68d7a1 commit e8f149a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/utils/types.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { getTableColumns } from '../../src/util/types';
import ContextProvider from '../testContext';

const context = ContextProvider.Instance;

describe("Test 'getTableColumns' function", () => {
it('should return the columns of a table', () => {
const columns = getTableColumns(context.models.emergency);

expect(columns).toBeDefined();
expect(columns).toBeInstanceOf(Array);
const expectedColumns = [
'id',
'name',
'date',
'restricted',
'active',
'createdAt',
'updatedAt',
'description',
'glideId',
'levelThree',
];
expectedColumns.forEach((column) => {
expect(columns).toContain(column);
});
});
it('should return an empty array if the table has no columns', () => {
const columns = getTableColumns({ _internals: { fields: {} } });
expect(columns).toBeDefined();
expect(columns).toBeInstanceOf(Array);
expect(columns).toHaveLength(0);
});
});

0 comments on commit e8f149a

Please sign in to comment.