Skip to content

Commit

Permalink
expand testing for addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeur7 committed Nov 18, 2024
1 parent 03d3266 commit 18ecc9a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 34 deletions.
24 changes: 24 additions & 0 deletions test/addresses.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {expect} from 'chai';
import {describe, it} from 'mocha';
import {shippoSdk} from "./helpers";

describe('TestAddresses', function() {
it('testCreateAddress', async () => {
const address = await shippoSdk.addresses.create({
name: 'Rachael',
street1: '1092 Indian Summer Ct',
city: 'San Jose',
state: 'CA',
zip: '95122',
country: 'US',
phone: '4159876543',
email: '[email protected]'
})

expect(address).to.not.be.null;
expect(address).to.be.an('object');
expect(address).to.have.property('objectId').that.is.a('string');
expect(address).to.have.property('name').that.is.equal('Rachael')
expect(address).to.have.property('country').that.is.equal('US');
})
})
81 changes: 48 additions & 33 deletions test/instalabel.test.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
import {expect} from 'chai';
import {describe, it} from 'mocha';
import {CarriersEnum, DistanceUnitEnum, WeightUnitEnum} from '../src/models/components';
import { CarriersEnum, DistanceUnitEnum, WeightUnitEnum} from '../src';
import {shippoSdk, getCarrierAccount} from "./helpers";

describe('TestInstalabel', function() {
it('testInstalabel', async () => {
const carrierAccount = await getCarrierAccount(CarriersEnum.Usps);

const transaction = await shippoSdk.transactions.create({
carrierAccount: carrierAccount.objectId,
servicelevelToken: "usps_ground_advantage",
shipment: {
addressFrom: {
name: "Rachael",
street1: "1092 Indian Summer Ct",
city: "San Jose",
state: "CA",
zip: "95122",
country: "US",
phone: "4159876543",
email: "[email protected]"
},
addressTo: {
name: "Mr Hippo",
street1: "965 Mission St #572",
city: "San Francisco",
state: "CA",
zip: "94103",
country: "US",
phone: "4151234567",
email: "[email protected]"
},
const addressFrom = await shippoSdk.addresses.create({
name: "Rachael",
street1: "1092 Indian Summer Ct",
city: "San Jose",
state: "CA",
zip: "95122",
country: "US",
phone: "4159876543",
email: "[email protected]"
})

const addressTo = await shippoSdk.addresses.create({
name: "Mr Hippo",
street1: "965 Mission St #572",
city: "San Francisco",
state: "CA",
zip: "94103",
country: "US",
phone: "4151234567",
email: "[email protected]"
})

const parcel = await shippoSdk.parcels.create(
{
length: "5",
width: "5",
height: "5",
distanceUnit: DistanceUnitEnum.Cm,
weight: "2",
massUnit: WeightUnitEnum.Lb
}
)

const shipment = await shippoSdk.shipments.create(
{
addressFrom: addressFrom,
addressTo: addressTo,
parcels: [
{
length: "5",
width: "5",
height: "5",
distanceUnit: DistanceUnitEnum.Cm,
weight: "2",
massUnit: WeightUnitEnum.Lb
}
parcel
]
}
)

const transaction = await shippoSdk.transactions.create({
carrierAccount: carrierAccount.objectId,
servicelevelToken: "usps_ground_advantage",
shipment: shipment
});

expect(transaction).to.not.be.null;
expect(transaction).to.have.property('parcel').that.is.a("string");
expect(transaction.rate.objectId).to.not.be.null;
expect(transaction.rate.servicelevelToken).to.be.equal("usps_ground_advantage");
expect(transaction.rate.currency).to.be.equal("USD");
});
});
2 changes: 1 addition & 1 deletion test/serviceGroups.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('TestListServiceGroups', function() {
expect(firstServiceGroup).to.have.property('description').that.is.a('string');
expect(firstServiceGroup).to.have.property('serviceLevels').that.is.an('array');
const firstServiceLevel = firstServiceGroup.serviceLevels[0];
expect(firstServiceLevel).to.have.property('account_object_id').that.is.an('string');
expect(firstServiceLevel).to.have.property('account_object_id').that.is.a('string');
expect(firstServiceLevel).to.have.property('service_level_token').that.is.an('string');
console.log(result);
console.log(firstServiceLevel);
Expand Down

0 comments on commit 18ecc9a

Please sign in to comment.