feat: 🎸 Fake mode for 121212121212, 201212121212 and 1212121212 (#35)

This commit is contained in:
Johan Öbrink 2021-01-15 09:40:48 +01:00 committed by GitHub
parent 28e04a9808
commit 8d264b9787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -104,10 +104,19 @@ describe('api', () => {
})
})
describe('fake', () => {
it('delivers fake data', async (done) => {
const status = await api.login('121212121212')
it('sets fake mode for the correct pnr:s', async () => {
let status
status = await api.login('121212121212')
expect(status.token).toEqual('fake')
status = await api.login('201212121212')
expect(status.token).toEqual('fake')
status = await api.login('1212121212')
expect(status.token).toEqual('fake')
})
it('delivers fake data', async (done) => {
api.on('login', async () => {
const user = await api.getUser()
expect(user).toEqual({
@ -125,6 +134,7 @@ describe('api', () => {
done()
})
await api.login('121212121212')
})
})
})

View File

@ -55,7 +55,7 @@ export class Api extends EventEmitter {
}
async login(personalNumber: string): Promise<LoginStatusChecker> {
if (personalNumber === '121212121212') return this.fakeMode()
if (personalNumber.endsWith('1212121212')) return this.fakeMode()
this.isFake = false