Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiandupont committed Feb 11, 2022
1 parent c80b731 commit f3e030b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 63 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
"trailingComma": "es5"
},
"jest": {
"setupFiles": [
"<rootDir>/test/helpers.js"
],
"moduleFileExtensions": [
"js",
"ts"
Expand Down
62 changes: 60 additions & 2 deletions src/rules/types.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,65 @@
/* global assertJSONBReport, assertTextReport, assertIdentityReport */

import * as types from './types';

const assertReport = (
mockReporter,
expectedRule,
expectedIdentifier,
expectedMessage,
expectedSuggestedMigration
) => {
expect(mockReporter).toBeCalledWith(
expect.objectContaining({
rule: expectedRule,
identifier: expectedIdentifier,
message: expectedMessage,
suggestedMigration: expectedSuggestedMigration,
})
);
};

const assertJSONBReport = (
mockReporter,
expectedIdentifier,
expectedSuggestedMigration
) => {
assertReport(
mockReporter,
'prefer-jsonb-to-json',
expectedIdentifier,
'Prefer JSONB to JSON types',
expectedSuggestedMigration
);
};

const assertTextReport = (
mockReporter,
expectedIdentifier,
expectedColumnType,
expectedSuggestedMigration
) => {
assertReport(
mockReporter,
'prefer-text-to-varchar',
expectedIdentifier,
`Prefer text to ${expectedColumnType} types`,
expectedSuggestedMigration
);
};

const assertIdentityReport = (
mockReporter,
expectedIdentifier,
expectedSuggestedMigration
) => {
assertReport(
mockReporter,
'prefer-identity-to-serial',
expectedIdentifier,
'Prefer IDENTITY to type SERIAL',
expectedSuggestedMigration
);
};

describe('types', () => {
describe('prefer-jsonb-to-json', () => {
it('no tables has no errors', () => {
Expand Down
58 changes: 0 additions & 58 deletions test/helpers.js

This file was deleted.

0 comments on commit f3e030b

Please sign in to comment.