-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a2f53a
commit 94abb1c
Showing
4 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { createOperator } from '../../../src/operations/operators'; | ||
import { options1 } from '../../utils'; | ||
|
||
describe('operations', () => { | ||
describe('operators', () => { | ||
describe('createOperator', () => { | ||
const createOperatorFn = createOperator(options1); | ||
|
||
it('should return a function', () => { | ||
expect(createOperatorFn).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = createOperatorFn('===', { | ||
left: 'box', | ||
right: 'box', | ||
procedure: 'area_equal_function', | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'CREATE OPERATOR === (PROCEDURE = "area_equal_function", LEFTARG = "box", RIGHTARG = "box");' | ||
); | ||
}); | ||
|
||
it('should return sql statement with operatorOptions', () => { | ||
const statement = createOperatorFn('===', { | ||
left: 'box', | ||
right: 'box', | ||
procedure: 'area_equal_function', | ||
commutator: '===', | ||
negator: '!==', | ||
restrict: 'area_restriction_function', | ||
join: 'area_join_function', | ||
hashes: true, | ||
merges: true, | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'CREATE OPERATOR === (PROCEDURE = "area_equal_function", LEFTARG = "box", RIGHTARG = "box", COMMUTATOR = ===, NEGATOR = !==, RESTRICT = "area_restriction_function", JOIN = "area_join_function", HASHES, MERGES);' | ||
); | ||
}); | ||
|
||
it('should return sql statement with schema', () => { | ||
const statement = createOperatorFn( | ||
{ name: '===', schema: 'myschema' }, | ||
{ | ||
left: 'box', | ||
right: 'box', | ||
procedure: 'area_equal_function', | ||
} | ||
); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'CREATE OPERATOR myschema.=== (PROCEDURE = "area_equal_function", LEFTARG = "box", RIGHTARG = "box");' | ||
); | ||
}); | ||
|
||
describe('reverse', () => { | ||
it('should contain a reverse function', () => { | ||
expect(createOperatorFn.reverse).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = createOperatorFn.reverse('===', { | ||
left: 'box', | ||
right: 'box', | ||
procedure: 'area_equal_function', | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toBe('DROP OPERATOR ===("box", "box");'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { dropOperator } from '../../../src/operations/operators'; | ||
import { options1 } from '../../utils'; | ||
|
||
describe('operations', () => { | ||
describe('operators', () => { | ||
describe('dropOperator', () => { | ||
const dropOperatorFn = dropOperator(options1); | ||
|
||
it('should return a function', () => { | ||
expect(dropOperatorFn).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = dropOperatorFn('^', { | ||
left: 'integer', | ||
right: 'integer', | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'DROP OPERATOR ^("integer", "integer");' | ||
); | ||
}); | ||
|
||
it('should return sql statement with dropOptions', () => { | ||
const statement = dropOperatorFn('~', { | ||
right: 'bit', | ||
ifExists: true, | ||
cascade: true, | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'DROP OPERATOR IF EXISTS ~("none", "bit") CASCADE;' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { dropOperatorFamily } from '../../../src/operations/operators'; | ||
import { options1 } from '../../utils'; | ||
|
||
describe('operations', () => { | ||
describe('operators', () => { | ||
describe('dropOperatorFamily', () => { | ||
const dropOperatorFamilyFn = dropOperatorFamily(options1); | ||
|
||
it('should return a function', () => { | ||
expect(dropOperatorFamilyFn).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = dropOperatorFamilyFn('float_ops', 'btree'); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'DROP OPERATOR FAMILY "float_ops" USING btree;' | ||
); | ||
}); | ||
|
||
it('should return sql statement with dropOptions', () => { | ||
const statement = dropOperatorFamilyFn('float_ops', 'btree', { | ||
ifExists: true, | ||
cascade: true, | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'DROP OPERATOR FAMILY IF EXISTS "float_ops" USING btree CASCADE;' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |