Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Backend Utility Service', () => {

it('should throw back the error when callback was provided', () => {
gridOptionMock.backendServiceApi!.onError = undefined;
expect(() => service.onBackendError('some error', gridOptionMock.backendServiceApi!)).toThrow('');
expect(() => service.onBackendError('some error', gridOptionMock.backendServiceApi!)).toThrow('some error');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ describe('ExtensionService', () => {
() => undefined as unknown as GridService
);

expect(() => service.bindDifferentExtensions()).toThrow('');
expect(() => service.bindDifferentExtensions()).toThrow(
'[Slickgrid-Universal] the RowBasedEdit Plugin requires a GridService to be configured and available'
);
});

it('should register the ColumnPicker addon when "enableColumnPicker" is set in the grid options', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('GraphqlService', () => {

it('should throw an error when no service options exists after service init', () => {
service.init(undefined as any);
expect(() => service.buildQuery()).toThrow('');
expect(() => service.buildQuery()).toThrow('GraphQL Service requires the "datasetName" property to properly build the GraphQL query');
});

it('should throw an error when no dataset is provided in the service options after service init', () => {
Expand All @@ -121,7 +121,7 @@ describe('GraphqlService', () => {

it('should throw an error when no column definitions is provided in the service options after service init', () => {
service.init({ datasetName: 'users' });
expect(() => service.buildQuery()).toThrow('');
expect(() => service.buildQuery()).toThrow('GraphQL Service requires the "datasetName" property to properly build the GraphQL query');
});

it('should return a simple query with pagination set and nodes that includes "id" and the other 2 fields properties', () => {
Expand Down Expand Up @@ -618,7 +618,9 @@ describe('GraphqlService', () => {
describe('processOnFilterChanged method', () => {
it('should throw an error when backendService is undefined', () => {
service.init(serviceOptions, paginationOptions, undefined);
expect(() => service.processOnFilterChanged(null as any, { grid: gridStub } as any)).toThrow('');
expect(() => service.processOnFilterChanged(null as any, { grid: gridStub } as any)).toThrow(
'Something went wrong in the GraphqlService, "backendServiceApi" is not initialized'
);
});

it('should throw an error when grid is undefined', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,31 +169,33 @@ describe('GraphqlQueryBuilder', () => {
});

it('should throw Error if find input items have zero props', () => {
expect(() => new GraphqlQueryBuilder('x').find({})).toThrow('');
expect(() => new GraphqlQueryBuilder('x').find({})).toThrow('Alias objects should only have one value. was passed: {}');
});

it('should throw Error if find input items have multiple props', () => {
expect(() => new GraphqlQueryBuilder('x').find({ a: 'z', b: 'y' })).toThrow('');
expect(() => new GraphqlQueryBuilder('x').find({ a: 'z', b: 'y' })).toThrow('Alias objects should only have one value. was passed: {"a":"z","b":"y"}');
});

it('should throw Error if find is undefined', () => {
expect(() => new GraphqlQueryBuilder('x').find()).toThrow('');
expect(() => new GraphqlQueryBuilder('x').find()).toThrow('find value can not be >>falsy<<');
});

it('should throw Error if no find values have been set', () => {
expect(() => `${new GraphqlQueryBuilder('x')}`).toThrow('');
expect(() => `${new GraphqlQueryBuilder('x')}`).toThrow(`return properties are not defined. use the 'find' function to defined them`);
});

it('should throw Error if find is not valid', () => {
expect(() => new GraphqlQueryBuilder('x').find(123)).toThrow('');
expect(() => new GraphqlQueryBuilder('x').find(123)).toThrow('cannot handle Find value of 123');
});

it('should throw Error if you accidentally pass an undefined', () => {
expect(() => new GraphqlQueryBuilder('x', undefined)).toThrow('');
expect(() => new GraphqlQueryBuilder('x', undefined)).toThrow('You have passed undefined as Second argument to "Query"');
});

it('should throw Error it is not an input object for alias', () => {
// @ts-ignore: 2345
expect(() => new GraphqlQueryBuilder('x', true)).toThrow('');
expect(() => new GraphqlQueryBuilder('x', true)).toThrow(
'Second argument to "Query" should be an alias name(String) or filter arguments(Object). What was passed is: true'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ describe('GridOdataService', () => {
describe('processOnFilterChanged method', () => {
it('should throw an error when backendService is undefined', () => {
service.init(serviceOptions, paginationOptions, undefined);
expect(() => service.processOnFilterChanged(null as any, { grid: gridStub } as any)).toThrow('');
expect(() => service.processOnFilterChanged(null as any, { grid: gridStub } as any)).toThrow(
'Something went wrong in the GridOdataService, "backendServiceApi" is not initialized'
);
});

it('should throw an error when grid is undefined', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('OdataService', () => {

it('should throw an error when odata options are null', () => {
service.options = undefined as any;
expect(() => service.buildQuery()).toThrow('');
expect(() => service.buildQuery()).toThrow('Odata Service requires certain options like "top" for it to work');
});

it('should return a query with $top pagination', () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/sql/src/services/__tests__/sql.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('SqlService', () => {

it('should throw an error when no service options exists after service init', () => {
service.init(undefined as any);
expect(() => service.buildQuery()).toThrow('');
expect(() => service.buildQuery()).toThrow('SQL Service requires the "tableName" property and columns to properly build the SQL query');
});

it('should throw an error when no tableName is provided in the service options after service init', () => {
Expand All @@ -121,7 +121,7 @@ describe('SqlService', () => {

it('should throw an error when no column definitions is provided in the service options after service init', () => {
service.init({ tableName: 'users' });
expect(() => service.buildQuery()).toThrow('');
expect(() => service.buildQuery()).toThrow('SQL Service requires the "tableName" property and columns to properly build the SQL query');
});

it('should return a simple SQL query with pagination set and includes all fields', () => {
Expand Down Expand Up @@ -533,7 +533,7 @@ describe('SqlService', () => {
describe('processOnFilterChanged method', () => {
it('should throw an error when grid is undefined', () => {
service.init(serviceOptions, paginationOptions, gridStub);
expect(() => service.processOnFilterChanged(null as any, { grid: undefined } as any)).toThrow('');
expect(() => service.processOnFilterChanged(null as any, { grid: undefined } as any)).toThrow('SQLService: "args" is not populated correctly');
});

it('should return a query with the new filter', () => {
Expand Down Expand Up @@ -1793,12 +1793,12 @@ describe('SqlService', () => {
});

it('should throw in _buildOrderByClause if options, tableName, or columns are missing', () => {
expect(() => service['buildOrderByClause']()).toThrow('');
expect(() => service['buildOrderByClause']()).toThrow('SQL Service requires the "tableName" property to properly build the SQL query');
service.options = { tableName: 'users' };
expect(() => service['buildOrderByClause']()).toThrow('');
expect(() => service['buildOrderByClause']()).toThrow('SQL Service requires the "tableName" property to properly build the SQL query');
service.options = undefined as any;
service['_columns'] = [{ id: 'foo', field: 'foo' }];
expect(() => service['buildOrderByClause']()).toThrow('');
expect(() => service['buildOrderByClause']()).toThrow('SQL Service requires the "tableName" property to properly build the SQL query');
});

it('should return empty string from _buildOrderByClause if no valid sorters', () => {
Expand Down
Loading
Loading