Comparing version 4.2.2 to 4.2.3
@@ -0,4 +1,3 @@ | ||
/* eslint-disable */ | ||
/* eslint-disable */ | ||
import got from 'got'; | ||
@@ -8,17 +7,44 @@ import BlueLinky from '../lib/index'; | ||
const VEHICLE_MOCK_DATA = { | ||
enrolledVehicleDetails: [ | ||
{ | ||
vehicleDetails: { | ||
nickname: 'JEST', | ||
vin: 'JEST_TESTING_1', | ||
regDate: 'JEST', | ||
brandIndicator: 'H', | ||
regId: 'H000000', | ||
gen: '2', | ||
name: 'JEST', | ||
}, | ||
}, | ||
{ | ||
vehicleDetails: { | ||
nickname: 'JEST', | ||
vin: 'JEST_TESTING_2', | ||
regDate: 'JEST', | ||
brandIndicator: 'H', | ||
regId: 'H000000', | ||
gen: '2', | ||
name: 'JEST', | ||
}, | ||
}, | ||
], | ||
}; | ||
describe('BlueLinky', () => { | ||
beforeEach(() => { | ||
(got as any).mockReturnValueOnce({ | ||
body: { | ||
'access_token': 'test', | ||
'refresh_token': 'test', | ||
'expires_in': 'test' | ||
}, | ||
statusCode: 200 | ||
}) | ||
.mockReturnValueOnce({ | ||
body: '[]', | ||
statusCode: 200 | ||
}); | ||
(got as any) | ||
.mockReturnValueOnce({ | ||
body: { | ||
access_token: 'test', | ||
refresh_token: 'test', | ||
expires_in: 'test', | ||
}, | ||
statusCode: 200, | ||
}) | ||
.mockReturnValueOnce({ | ||
body: JSON.stringify(VEHICLE_MOCK_DATA), | ||
statusCode: 200, | ||
}); | ||
}); | ||
@@ -31,5 +57,5 @@ | ||
pin: '1234', | ||
region: 'US' | ||
region: 'US', | ||
}); | ||
expect(client).toBeDefined(); | ||
@@ -41,3 +67,2 @@ | ||
}); | ||
}); | ||
@@ -51,4 +76,4 @@ | ||
pin: '1234', | ||
region: 'KR' | ||
}) | ||
region: 'KR', | ||
}); | ||
}).toThrowError('Your region is not supported yet.'); | ||
@@ -62,3 +87,3 @@ }); | ||
pin: '1234', | ||
region: 'US' | ||
region: 'US', | ||
}); | ||
@@ -69,5 +94,37 @@ | ||
}); | ||
}); | ||
it('getVehicle throws error on bad input', (done) => { | ||
const client = new BlueLinky({ | ||
username: 'someone@gmai.com', | ||
password: 'hunter1', | ||
pin: '1234', | ||
region: 'US', | ||
}); | ||
client.on('ready', () => { | ||
expect(() => client.getVehicle('test')).toThrowError(); | ||
done(); | ||
}); | ||
}); | ||
it('getVehicle returns correct vehicle', (done) => { | ||
const client = new BlueLinky({ | ||
username: 'someone@gmai.com', | ||
password: 'hunter1', | ||
pin: '1234', | ||
region: 'US', | ||
}); | ||
client.on('ready', (vehicles) => { | ||
const veh1 = client.getVehicle('JEST_TESTING_1'); | ||
const veh2 = client.getVehicle('JEST_TESTING_2'); | ||
expect(veh1.vin).toEqual('JEST_TESTING_1'); | ||
expect(veh2.vin).toEqual('JEST_TESTING_2'); | ||
done(); | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "bluelinky", | ||
"version": "4.2.2", | ||
"version": "4.2.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
79044
38
1462