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

Updates #10: Add tests for Decorators.js #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SlyBouhafs
Copy link
Contributor

@SlyBouhafs SlyBouhafs commented Oct 31, 2020

Updates #10

Screen Shot 2020-10-31 at 20 46 19

I am not sure if the tests are actually sufficient, i was confused by the functions and didn't really know what to expect, i only tested for the truthiness of the returned descriptor.value. Do you have any feedback on what those functions do and how i can improve my tests? Or is this enough?

@SlyBouhafs SlyBouhafs requested a review from a team as a code owner October 31, 2020 19:38
@SlyBouhafs SlyBouhafs changed the title Updates #10: New tests for Decorators.js Updates #10: Add tests for Decorators.js Oct 31, 2020
@bluepnume
Copy link
Collaborator

Hi! These are decorators for class methods. You can test them by applying them to a class, e.g.

class Foo {
  value = 0

  @memoized
  foo() {
    this.value += 1;
    return this.value;
  }

  @promise
  bar() {
    return 'bar';
  }
}

let foo = new Foo();

let x = foo.foo()
x = foo.foo()
x = foo.foo()

// x should be 1

foo.bar().then(result => {
   // result should be 'bar'
})

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

Successfully merging this pull request may close these issues.

2 participants