|
1 | 1 | import { expectTypeTestsToPassAsync } from 'jest-tsd'; |
2 | 2 | import { a } from '../src/index'; |
| 3 | +import { defineFunctionStub } from './utils'; |
3 | 4 |
|
4 | 5 | // evaluates type defs in corresponding test-d.ts file |
5 | 6 | it('should not produce static type errors', async () => { |
@@ -258,4 +259,48 @@ describe('CustomType transform', () => { |
258 | 259 |
|
259 | 260 | expect(result).toMatchSnapshot(); |
260 | 261 | }); |
| 262 | + |
| 263 | + test('Implicit CustomType authorized by both group and authorized though its custom operation', () => { |
| 264 | + const fn1 = defineFunctionStub({}); |
| 265 | + const s = a |
| 266 | + .schema({ |
| 267 | + getPostDetailsA: a |
| 268 | + .query() |
| 269 | + .arguments({content: a.customType({content: a.string()})}) |
| 270 | + .returns(a.customType({})) |
| 271 | + .handler([ |
| 272 | + a.handler.function(fn1), |
| 273 | + ]).authorization((allow) => [allow.authenticated(), allow.group("TestGroup")]), |
| 274 | + }); |
| 275 | + |
| 276 | + const result = s.transform().schema; |
| 277 | + |
| 278 | + expect(result).toMatchSnapshot(); |
| 279 | + }); |
| 280 | + |
| 281 | + test('Explicit CustomType authorized by both group and authorized though different custom operations', () => { |
| 282 | + const fn1 = defineFunctionStub({}); |
| 283 | + const s = a |
| 284 | + .schema({ |
| 285 | + testCustomType: a.customType({ content: a.string() }), |
| 286 | + getPostDetailsA: a |
| 287 | + .query() |
| 288 | + .arguments({}) |
| 289 | + .returns(a.ref("testCustomType")) |
| 290 | + .handler([ |
| 291 | + a.handler.function(fn1), |
| 292 | + ]).authorization((allow) => [allow.authenticated()]), |
| 293 | + getPostDetailsB: a |
| 294 | + .query() |
| 295 | + .arguments({}) |
| 296 | + .returns(a.ref("testCustomType")) |
| 297 | + .handler([ |
| 298 | + a.handler.function(fn1), |
| 299 | + ]).authorization((allow) => [allow.group("TestGroup")]) |
| 300 | + }); |
| 301 | + |
| 302 | + const result = s.transform().schema; |
| 303 | + |
| 304 | + expect(result).toMatchSnapshot(); |
| 305 | + }); |
261 | 306 | }); |
0 commit comments