Code Monkey home page Code Monkey logo

Comments (5)

waterplea avatar waterplea commented on May 20, 2024 2

This library is just a library of token so you make your apps without any direct access to global entities, because they might not be available in some environments. Universal package is the package of substitutes for those tokens for server side which also might work in other environments where they are missing. For example jest testing is a lot like universal as it is also emulated DOM. Is Jasmine/Karma you don't need mocks, because tokens are available as is. But you can easily mock them with spies etc. in unit tests.

from ng-web-apis.

waterplea avatar waterplea commented on May 20, 2024 1

When you configure TestBed you can add to providers something like this:

{
  provide: WINDOW,
  useValue: { 
    matchMedia(query: string): boolean {
      return query === '(min-width: 400px)';
    }
  }
}

for example, if your code depends on screen size by running window.matchMedia and you want to test particular configuration

from ng-web-apis.

waterplea avatar waterplea commented on May 20, 2024

Hey 👋 You mean like for testing with jest? I believe you can already just use mocks from universal, as well as tokens from it. Please let me know if that works for you.

from ng-web-apis.

batbrain9392 avatar batbrain9392 commented on May 20, 2024

For Jasmine/Karma. But will check with the mocks from universal.

But the mocks and tokens can be taken from universal, why maintain 2 repos with the same functionalities?

from ng-web-apis.

batbrain9392 avatar batbrain9392 commented on May 20, 2024

@waterplea Do you have an example of how these tokens can be mocked in Jasmine/Karma unit tests?

from ng-web-apis.

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.