diff --git a/tests/utils/types.spec.ts b/tests/utils/types.spec.ts new file mode 100644 index 0000000..05dd0dc --- /dev/null +++ b/tests/utils/types.spec.ts @@ -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); + }); +});