flotta-sdk
Version:
Flotta API wrapper
62 lines (55 loc) • 1.53 kB
text/typescript
import Flotta from '../src';
describe('Flotta.addShipment', () => {
it('should add shipment', () => {
const client = new Flotta('your-api-key', 'http://localhost:5000');
const token = 'your-token';
const storeId = 'store-id';
client.graphQLClient.mutate = jest.fn();
client.addShipment(token, storeId, {
delivery: {
customer: {
firstName: 'Darth',
secondName: 'Vader',
phone: '3663189261',
email: 'darth@starwars.com'
},
address: {
country: 'IT',
city: 'Roma',
street: 'Via Giovanni Giolitti',
number: '10',
zipCode: '20124'
},
position: {
coordinates: [9.213473, 45.466794],
type: 'Point'
},
time: '2017-08-30T19:33:51.149+0000',
intercom: 'Death Star'
},
order: {
paymentMethod: 'CASH',
currency: 'EUR',
total: 1600,
fee: 100,
items: [
{
name: 'Pizza Margherita',
quantity: 1,
price: 500,
},
{
name: 'Hamburger',
quantity: 1,
price: 1000,
description: 'Hamburger con insalata, pomodoro e formaggio'
}
],
notes: 'hamburger cottura al sangue, grazie.'
},
notes: 'in fondo al cortile a destra'
});
const mockedMutation = client.graphQLClient.mutate;
expect(mockedMutation.mock.calls.length).toBe(1);
});
});