strikedao / strikedao.com

Strike DAO is an experiment in participatory governance of blockchain art institutions.
https://strikedao.com
GNU General Public License v3.0
6 stars 1 forks source link

correct `votes.tally` test #124

Closed il3ven closed 2 years ago

il3ven commented 2 years ago

Earlier the result from votes.tally used to look like,

[
  {
    optionID: '2467y3kRa3s5m7KVsoojqbqsvLZ',
    votes: 2,
  },
  {
    optionID: '2467y7Ia1Oy04GB7CTmZfEp6lUm',
    votes: 1,
  }
]

Now, they look like,

[
  {
    optionID: '2467y3kRa3s5m7KVsoojqbqsvLZ',
    votes: 2,
    text: 'Tomatos'
  },
  {
    optionID: '2467y7Ia1Oy04GB7CTmZfEp6lUm',
    votes: 1,
    text: 'Bananas'
  },
  {
    optionID: '2467y4CYJ22UX2LPlCkYUIqz0j9',
    votes: 0,
    text: 'I like hamsters'
  }
]

This PR fixes the test according to the above mentioned change.

After changing the tests I found them to be still failing. That's when I found a bug in db.mjs.

     for (let option of question.options) {
-      const included = result.find(({ optionId }) => optionId === option.ksuid);
+      const included = result.find(({ optionID }) => optionID === option.ksuid);
       if (!included) {
-        result.push({ optionId: option.ksuid, votes: 0 });
+        result.push({ optionID: option.ksuid, votes: 0, text: option.name });
       }
     }
TimDaub commented 2 years ago

thank you very much