Skip to content

Commit

Permalink
test(apple): generatePass (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed Sep 7, 2022
1 parent 7746528 commit 5af5e57
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
testEnvironment: 'node',
coverageThreshold: {
global: {
lines: 18.55
lines: 81.50
}
}
}
2 changes: 1 addition & 1 deletion server/utils/AppleCryptoUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test('calculateSha1Hash', () => {
const filePath : string = './template-versions/apple/1/icon.png'
const actual : string = AppleCryptoUtils.calculateSha1Hash(filePath)
expect(actual).toBe('a9ce8210a5a240f8e6dd272ac395b26b33b6c7c1')
}),
})

test('generateManifestObject v1', () => {
const templateVersionDir : string = './template-versions/apple/1'
Expand Down
44 changes: 44 additions & 0 deletions server/utils/Passes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require('dotenv').config({ path: './.env.local.goerli' })
import { describe, expect, test } from '@jest/globals'
import { Platform } from '../interfaces'
import { config } from './Config'
import { Passes } from './Passes'
import fs from 'fs'

test('generatePass - Apple v1', () => {
const platform: Platform = Platform.Apple
const templateVersion: number = 1
const passportID: string = Math.floor(1 + (Math.random() * 840)).toString() // [1, 840]
const issueDateTimestamp: number = 1662541136 // September 7, 2022 8:58:56 AM
const address: string = '0x394b00B5De4E6f30292aCaC37f810Dd0672E211E'
const ensName: string = 'vitalik.eth'
const filePath: string = Passes.generatePass(
platform,
templateVersion,
passportID,
issueDateTimestamp,
address,
ensName
)
expect(filePath).toContain('passport_0x394b00B5De4E6f30292aCaC37f810Dd0672E211E.pkpass')
expect(fs.existsSync(filePath)).toBe(true)
})

test('generatePass - Apple v2', () => {
const platform: Platform = Platform.Apple
const templateVersion: number = 2
const passportID: string = Math.floor(1 + (Math.random() * 840)).toString() // [1, 840]
const issueDateTimestamp: number = 1662541136 // September 7, 2022 8:58:56 AM
const address: string = '0x394b00B5De4E6f30292aCaC37f810Dd0672E211E'
const ensName: string = 'vitalik.eth'
const filePath: string = Passes.generatePass(
platform,
templateVersion,
passportID,
issueDateTimestamp,
address,
ensName
)
expect(filePath).toContain('passport_0x394b00B5De4E6f30292aCaC37f810Dd0672E211E.pkpass')
expect(fs.existsSync(filePath)).toBe(true)
})

0 comments on commit 5af5e57

Please sign in to comment.