-
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 #50 from Hacksore/develop
Develop
- Loading branch information
Showing
33 changed files
with
6,781 additions
and
3,753 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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
plugins: ['@typescript-eslint'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
rules: { | ||
'no-console': 2, | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
} | ||
}, | ||
}; |
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,20 @@ | ||
name: auth | ||
|
||
on: push | ||
|
||
jobs: | ||
login: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node auth.js "US" | ||
- run: node auth.js "EU" | ||
env: | ||
HYUNDAI_USER: ${{secrets.HYUNDAI_USER}} | ||
HYUNDAI_PASS: ${{secrets.HYUNDAI_PASS}} | ||
HYUNDAI_PIN: ${{secrets.HYUNDAI_PIN}} |
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
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
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,52 +1,55 @@ | ||
/* eslint-disable */ | ||
import got from 'got'; | ||
|
||
import AmericanVehicle from '../lib/vehicles/americanVehicle'; | ||
import AmericanVehicle from '../lib/vehicles/american.vehicle'; | ||
import { AmericanController } from '../lib/controllers/american.controller'; | ||
|
||
import EuropeanVehicle from '../lib/vehicles/europianVehicle'; | ||
import EuropeanVehicle from '../lib/vehicles/european.vehicle'; | ||
import { EuropeanController } from '../lib/controllers/european.controller'; | ||
|
||
import CanadianVehicle from '../lib/vehicles/canadianVehicle'; | ||
import CanadianVehicle from '../lib/vehicles/canadian.vehicle'; | ||
import { CanadianController } from '../lib/controllers/canadian.controller'; | ||
|
||
jest.mock('got'); | ||
|
||
const referenceMap = { | ||
US: { | ||
controller: AmericanController, | ||
vehicle: AmericanVehicle, | ||
}, | ||
EU: { | ||
controller: EuropeanController, | ||
vehicle: EuropeanVehicle, | ||
}, | ||
CA: { | ||
controller: CanadianController, | ||
vehicle: CanadianVehicle, | ||
}, | ||
}; | ||
|
||
const getVehicle = region => { | ||
const referenceMap = { | ||
US: { | ||
controller: AmericanController, | ||
vehicle: AmericanVehicle, | ||
}, | ||
EU: { | ||
controller: EuropeanController, | ||
vehicle: EuropeanVehicle, | ||
}, | ||
CA: { | ||
controller: CanadianController, | ||
vehicle: CanadianVehicle, | ||
}, | ||
}; | ||
const Vehicle = referenceMap[region].vehicle; | ||
const Controller = referenceMap[region].controller; | ||
|
||
const controller = new referenceMap[region].controller({ | ||
const controller = new Controller({ | ||
username: '[email protected]', | ||
password: 'test', | ||
region: 'US', | ||
autoLogin: true, | ||
pin: '1234', | ||
vin: '4444444444444', | ||
vehicleId: undefined | ||
vehicleId: undefined, | ||
}); | ||
|
||
const vehicle = new referenceMap[region].vehicle( | ||
const vehicle = new Vehicle( | ||
{ | ||
nickname: 'Jest is best', | ||
name: 'Jest is best', | ||
vin: '444', | ||
regDate: 'test', | ||
brandIndicator: 'H', | ||
regId: '123123', | ||
gen: '2', | ||
name: 'Car', | ||
generation: '2', | ||
}, | ||
controller | ||
); | ||
|
@@ -58,7 +61,7 @@ describe('AmericanVehicle', () => { | |
const vehicle = getVehicle('US'); | ||
|
||
it('define new vehicle', () => { | ||
expect(vehicle.config.nickname).toEqual('Jest is best'); | ||
expect(vehicle.nickname()).toEqual('Jest is best'); | ||
}); | ||
|
||
it('call lock commmand', async () => { | ||
|
@@ -69,22 +72,21 @@ describe('AmericanVehicle', () => { | |
|
||
const response = await vehicle.lock(); | ||
expect(response).toEqual('Lock successful'); | ||
|
||
}); | ||
}); | ||
|
||
describe('CanadianVehicle', () => { | ||
const vehicle = getVehicle('CA'); | ||
|
||
it('define new vehicle', () => { | ||
expect(vehicle.config.nickname).toEqual('Jest is best'); | ||
expect(vehicle.nickname()).toEqual('Jest is best'); | ||
}); | ||
|
||
it('call lock commmand', async () => { | ||
(got as any).mockReturnValueOnce({ | ||
body: { | ||
result: { | ||
pAuth: 'test' | ||
pAuth: 'test', | ||
}, | ||
responseHeader: { | ||
responseCode: 0, | ||
|
@@ -111,9 +113,10 @@ describe('EuropeanVehicle', () => { | |
const vehicle = getVehicle('EU'); | ||
|
||
it('define new vehicle', () => { | ||
expect(vehicle.config.nickname).toEqual('Jest is best'); | ||
expect(vehicle.nickname()).toEqual('Jest is best'); | ||
}); | ||
|
||
// TODO: EU lead gets to write these :) | ||
// it('call lock commmand', async () => { | ||
// (got as any).mockReturnValueOnce({ | ||
// body: {}, | ||
|
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,28 @@ | ||
/* eslint-disable */ | ||
|
||
// test login for each region | ||
const BlueLinky = require('./dist/index'); | ||
const { HYUNDAI_USER, HYUNDAI_PASS, HYUNDAI_PIN } = process.env; | ||
const REGION_TO_TEST = process.argv[2]; | ||
|
||
const testRegionLogin = region => { | ||
const client = new BlueLinky({ | ||
username: HYUNDAI_USER, | ||
password: HYUNDAI_PASS, | ||
region: region, | ||
pin: HYUNDAI_PIN, | ||
deviceUuid: 'e8db10f3-7190-42ca-91db-7a6af6e5ea1f', | ||
}); | ||
|
||
client.on('ready', () => { | ||
console.log(`🦮 Connected to ${region} successfully 😎`); | ||
}); | ||
}; | ||
|
||
try { | ||
testRegionLogin(REGION_TO_TEST); | ||
} catch (error) { | ||
console.log(error); | ||
// exit with an error so the build job fails | ||
process.exit(1); | ||
} |
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.