Skip to content

How to test people's array from SimpleStorage contract ? #199

Answered by PatrickAlphaC
sharish13 asked this question in Q&A
Discussion options

You must be logged in to vote

You need to "pull out" the values from the struct with the same name as what's in the struct. The struct looks like this:

  struct People {
    uint256 favoriteNumber;
    string name;
  }

So to get those variables, you have to use the same names:

let { favoriteNumber, name } = await simpleStorage.people(0);
assert.equal(name, "Balajee")

Or, the second way you could do it:

const person = await simpleStorage.people(0)
assert.equal(person.name, "Balajee")

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by PatrickAlphaC
Comment options

You must be logged in to vote
2 replies
@gabrielantonyxaviour
Comment options

@PatrickAlphaC
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants