Skip to content

Commit

Permalink
chore: commenting out tests for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Sep 25, 2024
1 parent cd02542 commit 6feb539
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 151 deletions.
106 changes: 53 additions & 53 deletions test/tests/common.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
import {assert} from 'chai'
import {PermissionLevel, SessionKit} from '@wharfkit/session'
// import {assert} from 'chai'
// import {PermissionLevel, SessionKit} from '@wharfkit/session'

import {WalletPluginScatter} from '$lib'
import {mockFetch} from '$test/utils/mock-fetch'
import {MockStorage} from '$test/utils/mock-storage'
import {MockUserInterface} from '$test/utils/mock-ui'
// import {WalletPluginScatter} from '$lib'
// import {mockFetch} from '$test/utils/mock-fetch'
// import {MockStorage} from '$test/utils/mock-storage'
// import {MockUserInterface} from '$test/utils/mock-ui'

const mockChainDefinition = {
id: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
url: 'https://eos.greymass.com',
}
// const mockChainDefinition = {
// id: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
// url: 'https://eos.greymass.com',
// }

const mockPermissionLevel = PermissionLevel.from('wharfkit1111@test')
// const mockPermissionLevel = PermissionLevel.from('wharfkit1111@test')

const mockSessionKitOptions = {
appName: 'unittests',
chains: [mockChainDefinition],
fetch: mockFetch, // Required for unit tests
storage: new MockStorage(),
ui: new MockUserInterface(),
walletPlugins: [new WalletPluginScatter()],
}
// const mockSessionKitOptions = {
// appName: 'unittests',
// chains: [mockChainDefinition],
// fetch: mockFetch, // Required for unit tests
// storage: new MockStorage(),
// ui: new MockUserInterface(),
// walletPlugins: [new WalletPluginScatter()],
// }

suite('wallet plugin', function () {
this.timeout(120 * 1000)
this.slow(5 * 1000)
// suite('wallet plugin', function () {
// this.timeout(120 * 1000)
// this.slow(5 * 1000)

// test('login and sign', async function () {
// // test('login and sign', async function () {

// const kit = new SessionKit(mockSessionKitOptions)
// const { session } = await kit.login({
// chain: mockChainDefinition.id,
// permissionLevel: mockPermissionLevel,
// })
// assert.isTrue(session.chain.equals(mockChainDefinition))
// assert.isTrue(session.actor.equals(mockPermissionLevel.actor))
// assert.isTrue(session.permission.equals(mockPermissionLevel.permission))
// const result = await session.transact(
// {
// action: {
// authorization: [mockPermissionLevel],
// account: 'eosio.token',
// name: 'transfer',
// data: {
// from: mockPermissionLevel.actor,
// to: 'wharfkittest',
// quantity: '0.0001 EOS',
// memo: 'wharfkit/session wallet plugin template',
// },
// },
// },
// {
// broadcast: false,
// }
// )
// assert.isTrue(result.signer.equals(mockPermissionLevel))
// assert.equal(result.signatures.length, 1)
// })
})
// // const kit = new SessionKit(mockSessionKitOptions)
// // const { session } = await kit.login({
// // chain: mockChainDefinition.id,
// // permissionLevel: mockPermissionLevel,
// // })
// // assert.isTrue(session.chain.equals(mockChainDefinition))
// // assert.isTrue(session.actor.equals(mockPermissionLevel.actor))
// // assert.isTrue(session.permission.equals(mockPermissionLevel.permission))
// // const result = await session.transact(
// // {
// // action: {
// // authorization: [mockPermissionLevel],
// // account: 'eosio.token',
// // name: 'transfer',
// // data: {
// // from: mockPermissionLevel.actor,
// // to: 'wharfkittest',
// // quantity: '0.0001 EOS',
// // memo: 'wharfkit/session wallet plugin template',
// // },
// // },
// // },
// // {
// // broadcast: false,
// // }
// // )
// // assert.isTrue(result.signer.equals(mockPermissionLevel))
// // assert.equal(result.signatures.length, 1)
// // })
// })
196 changes: 98 additions & 98 deletions test/utils/mock-ui.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
import {
AbstractUserInterface,
cancelable,
Cancelable,
Checksum256,
LoginContext,
LoginOptions,
PermissionLevel,
PromptArgs,
PromptResponse,
UserInterface,
UserInterfaceLoginResponse,
} from '@wharfkit/session'

export class MockUserInterface extends AbstractUserInterface implements UserInterface {
readonly logging = false
public messages: string[] = []

translate(key) {
return key
}

log(message: string) {
this.messages.push(message)
if (this.logging) {
// eslint-disable-next-line no-console
console.info('MockUserInterface', message)
}
}

async login(context: LoginContext): Promise<UserInterfaceLoginResponse> {
let chainId = context.chain?.id
if (!chainId) {
chainId = Checksum256.from(context.chains[0].id)
}
let permissionLevel = context.permissionLevel
if (!permissionLevel) {
permissionLevel = PermissionLevel.from('mock@interface')
}
return {
chainId,
permissionLevel,
walletPluginIndex: 0,
}
}

async onError(error: Error) {
this.log('onError: ' + JSON.stringify(error))
}

async onLogin(options?: LoginOptions) {
this.log('onLogin: ' + JSON.stringify(options))
}

async onLoginComplete() {
this.log('onLoginComplete')
}

async onTransact() {
this.log('onTransact')
}

async onTransactComplete() {
this.log('onTransactComplete')
}

async onSign() {
this.log('onSign')
}

async onSignComplete() {
this.log('onSignComplete')
}

async onBroadcast() {
this.log('onBroadcast')
}

async onBroadcastComplete() {
this.log('onBroadcastComplete')
}

prompt(args: PromptArgs): Cancelable<PromptResponse> {
this.log('prompt' + JSON.stringify(args))
return cancelable(new Promise(() => {}), (canceled) => {
// do things to cancel promise
throw canceled
})
}

status(message: string) {
this.log(`status:('${message}')`)
}

addTranslations(): void {
this.log('addTranslations')
}
}
// import {
// AbstractUserInterface,
// cancelable,
// Cancelable,
// Checksum256,
// LoginContext,
// LoginOptions,
// PermissionLevel,
// PromptArgs,
// PromptResponse,
// UserInterface,
// UserInterfaceLoginResponse,
// } from '@wharfkit/session'

// export class MockUserInterface extends AbstractUserInterface implements UserInterface {
// readonly logging = false
// public messages: string[] = []

// translate(key) {
// return key
// }

// log(message: string) {
// this.messages.push(message)
// if (this.logging) {
// // eslint-disable-next-line no-console
// console.info('MockUserInterface', message)
// }
// }

// async login(context: LoginContext): Promise<UserInterfaceLoginResponse> {
// let chainId = context.chain?.id
// if (!chainId) {
// chainId = Checksum256.from(context.chains[0].id)
// }
// let permissionLevel = context.permissionLevel
// if (!permissionLevel) {
// permissionLevel = PermissionLevel.from('mock@interface')
// }
// return {
// chainId,
// permissionLevel,
// walletPluginIndex: 0,
// }
// }

// async onError(error: Error) {
// this.log('onError: ' + JSON.stringify(error))
// }

// async onLogin(options?: LoginOptions) {
// this.log('onLogin: ' + JSON.stringify(options))
// }

// async onLoginComplete() {
// this.log('onLoginComplete')
// }

// async onTransact() {
// this.log('onTransact')
// }

// async onTransactComplete() {
// this.log('onTransactComplete')
// }

// async onSign() {
// this.log('onSign')
// }

// async onSignComplete() {
// this.log('onSignComplete')
// }

// async onBroadcast() {
// this.log('onBroadcast')
// }

// async onBroadcastComplete() {
// this.log('onBroadcastComplete')
// }

// prompt(args: PromptArgs): Cancelable<PromptResponse> {
// this.log('prompt' + JSON.stringify(args))
// return cancelable(new Promise(() => {}), (canceled) => {
// // do things to cancel promise
// throw canceled
// })
// }

// status(message: string) {
// this.log(`status:('${message}')`)
// }

// addTranslations(): void {
// this.log('addTranslations')
// }
// }

0 comments on commit 6feb539

Please sign in to comment.