Git Product home page Git Product logo

Comments (11)

ebebbington avatar ebebbington commented on June 14, 2024 1

@crookse ive tested it on master and it works fine :S

from rhum.

ebebbington avatar ebebbington commented on June 14, 2024

hanks @rags2riches-prog and apologies you encountered this, we'll look into this when we can πŸ‘

from rhum.

rags2riches-prog avatar rags2riches-prog commented on June 14, 2024

@ebebbington Are there any mantainers for this project to be kept relevant and up to date ?

from rhum.

ebebbington avatar ebebbington commented on June 14, 2024

@rags2riches-prog there are, and whilst we intend on doing so for a long time, some of us haven't been able to, and all of us are having a few real life commitments we need to take care of, alongside full time jobs

I'm going to start looking into this now for you

from rhum.

ebebbington avatar ebebbington commented on June 14, 2024

@rags2riches-prog what rhum and deno version are you using? it seems to work fine for me:

import { Rhum } from "./mod.ts"

class Router {
    async handle(request: Request): Promise<string|Error> {
        return 'test'
    }
}

Rhum.testPlan("a.ts", () => {
    Rhum.testSuite("router", () => {
        Rhum.testCase("handle()", async () => {
            const req = new Request("https://google.com")
            const router = Rhum.mock(Router).create()
            Rhum.asserts.assertEquals(router.calls.handle, 0)
            Rhum.asserts.assertEquals(await router.handle(req), "test")
        })
    })
})

Rhum.run()
$ deno test -A a.ts

from rhum.

rags2riches-prog avatar rags2riches-prog commented on June 14, 2024

@ebebbington thanks for coming back to me, much appreciated.

I am running the last versions for both Deno and Rhum.

The behavior you are trying to reproduce isn't quite the same than the one reported in the OP.

const req = new Request("http://localhost:8080", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify(fakeData)
  })

The Request API gets an optional object with details about the request method, headers and a body payload.
The TypeError suggests the property method of the mocked router cannot be read, unless I am misunderstanding the error.

from rhum.

ebebbington avatar ebebbington commented on June 14, 2024

@ebebbington thanks for coming back to me, much appreciated.

I am running the last versions for both Deno and Rhum.

The behavior you are trying to reproduce isn't quite the same than the one reported in the OP.

const req = new Request("http://localhost:8080", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify(fakeData)
  })

The Request API gets an optional object with details about the request method, headers and a body payload. The TypeError suggests the property method of the mocked router cannot be read, unless I am misunderstanding the error.

I don’t suppose you could try importing master of Rhum? Maybe master and the latest version differ somehow: import { Rhum } from β€œ https://raw.githubusercontent.com/drashland/rhum/master/mod.ts”

from rhum.

crookse avatar crookse commented on June 14, 2024

this may be an issue with how the mock logic works when it copies over methods and properties. if you (@ebebbington) don't get to it, i'll check it out to see if a native request's properties and methods are all copied over into the mock

based on the method property being undefined, it makes me think it's not being copied over

from rhum.

crookse avatar crookse commented on June 14, 2024

@ebebbington i verified that this is a bug. your test is missing the part that surfaces the bug. you need to access request.method in your handle() method. that's when TypeError: Cannot read properties of undefined (reading 'method') shows up

from rhum.

crookse avatar crookse commented on June 14, 2024

@rags2riches-prog, sorry for being late on this. i have a pull request open. it includes a fix for the issue you are seeing.

from rhum.

crookse avatar crookse commented on June 14, 2024

hey @rags2riches-prog , v1.1.12 was released: https://github.com/drashland/rhum/releases/tag/v1.1.12.

it includes the fix for the issue you are seeing. you shouldn't have to change any code. it should just work, but please let me know if it doesn't. thanks for raising this issue!

from rhum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.