Created
May 3, 2020 06:33
-
-
Save marekkirejczyk/fcc6d98c8b012863351384dc17fd56d1 to your computer and use it in GitHub Desktop.
findEventFragment.test.ts
This file contains hidden or 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
import {expect} from 'chai'; | |
import {findEventFragment} from '../../src/matchers/findEventFragment'; | |
const contract = { | |
interface: { | |
events: | |
{ | |
'One(uint256,string,bytes32)': | |
{ | |
name: 'One', | |
anonymous: false, | |
inputs: [Array], | |
type: 'event', | |
_isFragment: true | |
}, | |
'Two(uint256,string)': | |
{ | |
name: 'Two', | |
anonymous: false, | |
inputs: [Array], | |
type: 'event', | |
_isFragment: true | |
}, | |
'Two(string)': | |
{ | |
name: 'Two', | |
anonymous: false, | |
inputs: [Array], | |
type: 'event', | |
_isFragment: true | |
}, | |
'Arrays(uint256[3],bytes32[2])': | |
{ | |
name: 'Arrays', | |
anonymous: false, | |
inputs: [Array], | |
type: 'event', | |
_isFragment: true | |
} | |
}, | |
} | |
} as any; | |
describe('UNIT: findEventFragment', () => { | |
it('Return undefined if can`t find', async () => { | |
expect(findEventFragment(contract, 'Seven')).to.be.undefined; | |
}); | |
it('Find simple name', async () => { | |
expect(findEventFragment(contract, 'One')).to.include({ | |
name: 'One', | |
anonymous: false, | |
type: 'event', | |
_isFragment: true | |
}); | |
}); | |
it('Find canonical name', async () => { | |
expect(findEventFragment(contract, 'One(uint256,string,bytes32)')).to.include({ | |
name: 'One', | |
anonymous: false, | |
type: 'event', | |
_isFragment: true | |
}); | |
}); | |
it('Throw if ambiguous name', async () => { | |
expect(() => findEventFragment(contract, 'Two')) | |
.to.throw('Ambiguous event Two, could be Two(uint256,string) or Two(string)'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment