-
Notifications
You must be signed in to change notification settings - Fork 0
/
traveldata.test.js
39 lines (33 loc) · 1.33 KB
/
traveldata.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// traveldata.test.js
const request = require('supertest');
const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');
const fs = require('fs');
const path = require('path');
// Import your typeDefs and resolvers for the traveldata module
const travelDataTypeDefs = gql(fs.readFileSync(path.join(__dirname, './src/graphql/traveldata/schema.graphql'), 'utf8'));
const travelDataResolvers = require('./src/graphql/traveldata/resolvers');
// Set up Apollo Server for traveldata
const travelDataServer = new ApolloServer({ typeDefs: travelDataTypeDefs, resolvers: travelDataResolvers });
const travelDataApp = express();
travelDataServer.applyMiddleware({ app: travelDataApp });
describe('TravelData GraphQL Integration Tests', () => {
test('Fetches bookings', async () => {
const query = `
query {
bookings {
bookingId
noOfAdults
// ... other fields
}
}
`;
const response = await request(travelDataApp)
.post('/graphql')
.send({ query });
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('data.bookings');
// Add more assertions based on the expected shape of your data
});
// Add more tests for different queries and mutations specific to traveldata
});