Giter Site home page Giter Site logo

Comments (2)

gregkerzhner avatar gregkerzhner commented on June 9, 2024

I was able to test using routing using the following strategy (I am using DPLRouteHandler subclasses, not block based routes). Examples are in swift (and might not compile, just giving my general strategy here)

Make route handlers classes configurable for stubbing:

class MyRouter: DPLDeepLinkRouter {
    init(oneHandler: OneHandler.Type = OneHandler.self,
        twoHandler: TwoHandler.Type = TwoHandler.self
        ) {
        super.init()
        self["one"] =  forumsRouteHandler
        self["two"] = articleRouteHandler
    }
}

I created a dummy route handler which always fails when hit

class DummyFailOneHandler: OneHandler {
    public override func targetViewController() -> UIViewController! {
        fatalError("I should not be called")
        return nil
    }

    override public func viewControllerForPresentingDeepLink(deepLink: DPLDeepLink!) -> UIViewController! {
        fatalError("I should not be called")
        return nil
    }
}

In my test, when I want to confirm that a certain route has been hit, make all other route handlers fail by stubbing them with this failed handler.

router = MyRouter(oneHandler: DummyFailOneHandler.self, twoHandler: TwoHandler.self)
let nsUrl = NSURL(string: "two")
let handled = router?.handleURL(nsUrl, withCompletion: nil)
expect(handled).to(beTrue())

This way if handleUrl returns true I know that the route has been handled by the specific route handler that is supposed to handle it (because all other route handlers automatically fail).

Sorry, code above is not tested for syntax, just a general idea.

from deeplinkkit.

wumuu avatar wumuu commented on June 9, 2024

it is a good way to deal with my complex project file

from deeplinkkit.

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.