Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.update is not a function #72

Open
gracezhouu opened this issue May 25, 2020 · 1 comment
Open

app.update is not a function #72

gracezhouu opened this issue May 25, 2020 · 1 comment

Comments

@gracezhouu
Copy link

Hi Guys
When I go to the second step, and basic update function and run the test,

/**
 * `update` transforms the `model` based on the `action`.
 * @param {String} action - the desired action to perform on the model.
 * @param {Object} model - the App's (current) model (or "state").
 * @return {Object} new_model - the transformed model.
 */
function update(action, model) {
 switch (action) {                  // action (String) determines which case
   default:                         // if action unrecognised or undefined,
     return model;                  // return model unmodified
 }    // default? https://softwareengineering.stackexchange.com/a/201786/211301
}

it supposed to pass the test, but there is the following error message, anyone know why?

TAP version 13

model (Object) has desired keys

ok 1 todos and hash keys are present.
ok 2 model.todos is an Array

update default case should return model unmodified

/Users/rushlin/Downloads/mystuff/javascript-todo-list/test/todo-app1.test.js:19
const unmodified_model = app.update('UNKNOWN_ACTION', model);
^

TypeError: app.update is not a function
at Test. (/Users/rushlin/Downloads/mystuff/javascript-todo-list/test/todo-app1.test.js:19:32)
at Test.bound [as _cb] (/Users/rushlin/node_modules/tape/lib/test.js:84:32)
at Test.run (/Users/rushlin/node_modules/tape/lib/test.js:101:31)
at Test.bound [as run] (/Users/rushlin/node_modules/tape/lib/test.js:84:32)
at Immediate.next (/Users/rushlin/node_modules/tape/lib/results.js:83:19)
at processImmediate (internal/timers.js:456:21)
shanshandeMacBook-Pro:javascript-todo-list rushlin$

@nelsonic
Copy link
Member

Hi @gracezhouu thanks for opening this issue to let us know you are stuck. 👍
From your stack trace you appear to be following the Todo List Tutorial: https://github.com/dwyl/javascript-todo-list-tutorial is that correct?

Please confirm that you have exported the update function in your /lib/todo-app.js
e.g:

https://github.com/dwyl/javascript-todo-list-tutorial/blob/e6736add9df1f46035f8a9d1dbdc14c71a7cdb41/lib/todo-app.js#L344-L354

If update is not exported at the end of your /lib/todo-app.js file then it won't be accessible in your tests so you will see this app.update is not a function error.

If possible, commit your code to GitHub so we can help you debug it much faster. 💡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants