Skip to content

Commit

Permalink
feat: add tests for new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnordelo committed Jan 8, 2025
1 parent 44c6491 commit 72fdfeb
Showing 1 changed file with 64 additions and 11 deletions.
75 changes: 64 additions & 11 deletions packages/macros/src/tests/test_with_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,42 @@ fn test_with_erc20_no_initializer() {
let attribute = "(ERC20)";
let item = indoc!(
"
#[starknet::contract]
pub mod MyToken {
use openzeppelin_token::erc20::ERC20HooksEmptyImpl;
use starknet::ContractAddress;
#[starknet::contract]
pub mod MyToken {
use openzeppelin_token::erc20::ERC20HooksEmptyImpl;
use starknet::ContractAddress;
#[storage]
pub struct Storage {}
#[storage]
pub struct Storage {}
#[constructor]
fn constructor(ref self: ContractState) {
}
}
"
#[constructor]
fn constructor(ref self: ContractState) {
}
}
"
);
let result = get_string_result(attribute, item);
assert_snapshot!(result);
}

#[test]
fn test_with_erc20_no_hooks_impl() {
let attribute = "(ERC20)";
let item = indoc!(
"
#[starknet::contract]
pub mod MyToken {
use starknet::ContractAddress;
#[storage]
pub struct Storage {}
#[constructor]
fn constructor(ref self: ContractState) {
self.erc20.initializer(\"MyToken\", \"MTK\");
}
}
"
);
let result = get_string_result(attribute, item);
assert_snapshot!(result);
Expand Down Expand Up @@ -272,6 +295,36 @@ fn test_with_vesting_no_initializer() {
assert_snapshot!(result);
}

#[test]
fn test_with_vesting_no_schedule() {
let attribute = "(Vesting, Ownable)";
let item = indoc!(
"
#[starknet::contract]
pub mod VestingWallet {
use starknet::ContractAddress;
#[storage]
pub struct Storage {}
#[constructor]
fn constructor(
ref self: ContractState,
beneficiary: ContractAddress,
start: u64,
duration: u64,
cliff_duration: u64,
) {
self.ownable.initializer(beneficiary);
self.vesting.initializer(start, duration, cliff_duration);
}
}
"
);
let result = get_string_result(attribute, item);
assert_snapshot!(result);
}

#[test]
fn test_with_no_contract_attribute() {
let attribute = "(Ownable)";
Expand Down

0 comments on commit 72fdfeb

Please sign in to comment.