Skip to content

Commit

Permalink
add more createDomain test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Mar 5, 2024
1 parent ae14f81 commit 7575d78
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/operations/createDomain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ describe('operations', () => {
);
});

it('should return sql statement with domainOptions', () => {
it('should return sql statement with domainOptions collation and default', () => {
const statement = createDomainFn('us_postal_code', 'TEXT', {
collation: 'en_US',
default: '12345',
constraintName: 'us_postal_code_check',
});

expect(statement).toBeTypeOf('string');
Expand All @@ -54,7 +53,7 @@ describe('operations', () => {
);
});

it('should return sql statement with domainOptions.check', () => {
it('should return sql statement with domainOptions check', () => {
const statement = createDomainFn('us_postal_code', 'TEXT', {
check: "VALUE ~ '^d{5}$'",
});
Expand All @@ -65,6 +64,18 @@ describe('operations', () => {
);
});

it('should return sql statement with domainOptions constraintName and notNull', () => {
const statement = createDomainFn('us_postal_code', 'TEXT', {
constraintName: 'us_postal_code_check',
notNull: true,
});

expect(statement).toBeTypeOf('string');
expect(statement).toBe(
'CREATE DOMAIN "us_postal_code" AS TEXT CONSTRAINT "us_postal_code_check" NOT NULL;'
);
});

it('should throw when notNull and check are passed', () => {
expect(() =>
createDomainFn('us_postal_code', 'TEXT', {
Expand Down

0 comments on commit 7575d78

Please sign in to comment.