-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Hacksore/develop
- Loading branch information
Showing
14 changed files
with
594 additions
and
1,335 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
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ import got from 'got'; | |
import BlueLinky from '../lib/index'; | ||
jest.mock('got'); | ||
|
||
const gotMock = got as any; | ||
|
||
const VEHICLE_MOCK_DATA = { | ||
enrolledVehicleDetails: [ | ||
{ | ||
|
@@ -31,6 +33,30 @@ const VEHICLE_MOCK_DATA = { | |
], | ||
}; | ||
|
||
describe('BlueLinky', () => { | ||
it('calls error even when bad creds', done => { | ||
gotMock.mockReturnValueOnce({ | ||
body: { | ||
error: { | ||
message: 'you did something wrong!', | ||
}, | ||
}, | ||
statusCode: 401, | ||
}); | ||
|
||
const client = new BlueLinky({ | ||
username: '[email protected]', | ||
password: '123', | ||
pin: '1234', | ||
region: 'US', | ||
}); | ||
|
||
client.on('error', error => { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('BlueLinky', () => { | ||
beforeEach(() => { | ||
(got as any) | ||
|
@@ -75,9 +101,9 @@ describe('BlueLinky', () => { | |
}).toThrowError('Your region is not supported yet.'); | ||
}); | ||
|
||
it('ready event is called after login', (done) => { | ||
it('ready event is called after login', done => { | ||
const client = new BlueLinky({ | ||
username: 'someone@gmai.com', | ||
username: 'someone@gmail.com', | ||
password: 'hunter1', | ||
pin: '1234', | ||
region: 'US', | ||
|
@@ -88,30 +114,29 @@ describe('BlueLinky', () => { | |
}); | ||
}); | ||
|
||
it('getVehicle throws error on bad input', (done) => { | ||
it('getVehicle throws error on bad input', done => { | ||
const client = new BlueLinky({ | ||
username: 'someone@gmai.com', | ||
username: 'someone@gmail.com', | ||
password: 'hunter1', | ||
pin: '1234', | ||
region: 'US', | ||
}); | ||
|
||
client.on('ready', () => { | ||
expect(() => client.getVehicle('test')).toThrowError(); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it('getVehicle returns correct vehicle', (done) => { | ||
it('getVehicle returns correct vehicle', done => { | ||
const client = new BlueLinky({ | ||
username: '[email protected]', | ||
password: 'hunter1', | ||
pin: '1234', | ||
region: 'US', | ||
}); | ||
|
||
client.on('ready', (vehicles) => { | ||
client.on('ready', vehicles => { | ||
const veh1 = client.getVehicle('JEST_TESTING_1'); | ||
const veh2 = client.getVehicle('JEST_TESTING_2'); | ||
|
||
|
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,48 @@ | ||
{ | ||
"vehicleStatus": { | ||
"dateTime": "2020-05-20T23:20:39Z", | ||
"acc": false, | ||
"trunkOpen": false, | ||
"doorLock": false, | ||
"defrostStatus": "false", | ||
"transCond": true, | ||
"doorLockStatus": "false", | ||
"doorOpen": { | ||
"frontRight": 1, | ||
"frontLeft": 1, | ||
"backLeft": 0, | ||
"backRight": 0 | ||
}, | ||
"airCtrlOn": false, | ||
"airTemp": { | ||
"unit": 1, | ||
"hvacTempType": 1, | ||
"value": "LO" | ||
}, | ||
"battery": { | ||
"batSignalReferenceValue": {}, | ||
"batSoc": 67, | ||
"batState": 0, | ||
"sjbDeliveryMode": 1 | ||
}, | ||
"ign3": false, | ||
"ignitionStatus": "false", | ||
"lowFuelLight": false, | ||
"sideBackWindowHeat": 0, | ||
"dte": { | ||
"unit": 3, | ||
"value": 142 | ||
}, | ||
"engine": false, | ||
"defrost": false, | ||
"hoodOpen": false, | ||
"airConditionStatus": "false", | ||
"steerWheelHeat": 0, | ||
"tirePressureLamp": { | ||
"tirePressureWarningLampRearLeft": 0, | ||
"tirePressureWarningLampFrontLeft": 0, | ||
"tirePressureWarningLampFrontRight": 0, | ||
"tirePressureWarningLampAll": 0, | ||
"tirePressureWarningLampRearRight": 0 | ||
}, | ||
"trunkOpenStatus": "false" | ||
} | ||
"dateTime": "2020-05-20T23:20:39Z", | ||
"acc": false, | ||
"trunkOpen": false, | ||
"doorLock": false, | ||
"defrostStatus": "false", | ||
"transCond": true, | ||
"doorLockStatus": "false", | ||
"doorOpen": { | ||
"frontRight": 1, | ||
"frontLeft": 1, | ||
"backLeft": 0, | ||
"backRight": 0 | ||
}, | ||
"airCtrlOn": false, | ||
"airTemp": { | ||
"unit": 1, | ||
"hvacTempType": 1, | ||
"value": "LO" | ||
}, | ||
"battery": { | ||
"batSignalReferenceValue": {}, | ||
"batSoc": 67, | ||
"batState": 0, | ||
"sjbDeliveryMode": 1 | ||
}, | ||
"ign3": false, | ||
"ignitionStatus": "false", | ||
"lowFuelLight": false, | ||
"sideBackWindowHeat": 0, | ||
"dte": { | ||
"unit": 3, | ||
"value": 142 | ||
}, | ||
"engine": false, | ||
"defrost": false, | ||
"hoodOpen": false, | ||
"airConditionStatus": "false", | ||
"steerWheelHeat": 0, | ||
"tirePressureLamp": { | ||
"tirePressureWarningLampRearLeft": 0, | ||
"tirePressureWarningLampFrontLeft": 0, | ||
"tirePressureWarningLampFrontRight": 0, | ||
"tirePressureWarningLampAll": 0, | ||
"tirePressureWarningLampRearRight": 0 | ||
}, | ||
"trunkOpenStatus": "false" | ||
} |
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
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
Oops, something went wrong.