-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match Foundry style contract name formats
- Loading branch information
Showing
2 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import test from 'ava'; | ||
|
||
import { isMatch } from './find-contract'; | ||
|
||
test('fully qualified - match', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'contracts/MyContract.sol:Foo', | ||
}; | ||
|
||
t.true(isMatch('contracts/MyContract.sol:Foo', sourceContract as any)); | ||
}); | ||
|
||
test('fully qualified without folder - match', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'MyContract.sol:Foo', | ||
}; | ||
|
||
t.true(isMatch('MyContract.sol:Foo', sourceContract as any)); | ||
}); | ||
|
||
test('short name - match', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'contracts/MyContract.sol:Foo', | ||
}; | ||
|
||
t.true(isMatch('Foo', sourceContract as any)); | ||
}); | ||
|
||
test('short name - match without folder', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'MyContract.sol:Foo', | ||
}; | ||
|
||
t.true(isMatch('Foo', sourceContract as any)); | ||
}); | ||
|
||
test('short name with .sol - no match', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'contracts/MyContract.sol:Foo', | ||
}; | ||
|
||
t.false(isMatch('MyContract.sol', sourceContract as any)); | ||
t.false(isMatch('Foo.sol', sourceContract as any)); | ||
}); | ||
|
||
test('short name with .sol - match', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'contracts/Foo.sol:Foo', | ||
}; | ||
|
||
t.true(isMatch('Foo.sol', sourceContract as any)); | ||
}); | ||
|
||
test('short name with .sol - match without folder', async t => { | ||
const sourceContract = { | ||
name: 'Foo', | ||
fullyQualifiedName: 'Foo.sol:Foo', | ||
}; | ||
|
||
t.true(isMatch('Foo.sol', sourceContract as any)); | ||
}); |
This file contains 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