-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters