Skip to content

Commit

Permalink
feat: 馃幐 Fake mode for 121212121212, 201212121212 and 1212121212 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanObrink committed Jan 15, 2021
1 parent 28e04a9 commit 8d264b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/api.test.ts
Expand Up @@ -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({
Expand All @@ -125,6 +134,7 @@ describe('api', () => {

done()
})
await api.login('121212121212')
})
})
})
2 changes: 1 addition & 1 deletion lib/api.ts
Expand Up @@ -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

Expand Down

0 comments on commit 8d264b9

Please sign in to comment.