UNPKG

meld-spec

Version:

Specification for the Meld scripting language

209 lines (208 loc) 5.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.callTests = void 0; /** * Test cases for the @call directive that all implementations must pass */ exports.callTests = [ // Direct method calls { name: 'get-request', input: '@call api.get [/users]', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'get', path: '/users' } }, description: 'Basic GET request' }, { name: 'post-request', input: '@call api.post [/users] {{ name: "test" }}', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'post', path: '/users', payload: { name: 'test' } } }, description: 'POST request with payload' }, // Endpoint calls { name: 'endpoint-get', input: '@call api.users.get', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', endpoint: 'users', method: 'get' } }, description: 'GET request using endpoint' }, { name: 'endpoint-post', input: '@call api.users.post {{ name: "test" }}', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', endpoint: 'users', method: 'post', payload: { name: 'test' } } }, description: 'POST request using endpoint with payload' }, // Path with variables { name: 'path-variables', input: '@call api.get [/users/${userId}/posts/${postId}]', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'get', path: '/users/${userId}/posts/${postId}' } }, description: 'Path with variable interpolation' }, // Query parameters { name: 'query-params', input: '@call api.get [/search?q=${query}&page=${page}]', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'get', path: '/search?q=${query}&page=${page}' } }, description: 'Path with query parameters' }, // Complex payload with variables { name: 'complex-payload', input: '@call api.users.post {{\n name: "${name}",\n age: 30,\n settings: {\n theme: "${theme}",\n notifications: true\n },\n tags: ["${tag1}", "${tag2}"]\n }}', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', endpoint: 'users', method: 'post', payload: { name: '${name}', age: 30, settings: { theme: '${theme}', notifications: true }, tags: ['${tag1}', '${tag2}'] } } }, description: 'Complex payload with nested structures' }, // Nested endpoint call { name: 'nested-endpoint', input: '@call api.users.posts.comments.get', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', endpoint: 'users.posts.comments', method: 'get' } }, description: 'Deeply nested endpoint call' }, // Data variable payload { name: 'data-payload', input: '@call api.post [/data] "#{request_data}"', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'post', path: '/data', payload: '#{request_data}' } }, description: 'Payload using data variable' }, // PUT request { name: 'put-request', input: '@call api.put [/users/${id}] {{\n name: "updated"\n }}', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'put', path: '/users/${id}', payload: { name: 'updated' } } }, description: 'PUT request with payload' }, // PATCH request { name: 'patch-request', input: '@call api.patch [/users/${id}] {{\n active: true\n }}', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'patch', path: '/users/${id}', payload: { active: true } } }, description: 'PATCH request with payload' }, // DELETE request { name: 'delete-request', input: '@call api.delete [/users/${id}]', expected: { type: 'Directive', directive: { kind: 'call', api: 'api', method: 'delete', path: '/users/${id}' } }, description: 'DELETE request' } ];