Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boar-angular2-testing

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boar-angular2-testing

This is an angular2 test helper collection.

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Boar Angular2 Testing

This is an angular2 test helper collection.

Install

npm install --save-dev boar-angular2-testing

How to provide

import { SyncMockBackend } from 'boar-angular2-testing';

beforEachProvider(() => {
  SyncMockBackend,
  provide(Http, {
    useFactory: (backend, defaultOptions) => {
      return new Http(backend, defaultOptions);
    },
    deps: [SyncMockBackend, BaseRequestOptions]
  })
});

Manual flush


const backend = new SyncMockBackend();
backend
  .whenGET('http://test.me/api/templates/abc123')
  .respondWithSuccess({ _id: 5, name: 'Test template' });
backend
  .whenDELETE('http://test.me/api/templates/abc123')
  .respondWithError('Something went wrong!'));
service.load();
backend.flushNext();
service.delete();
backend.flushNext();

Auto flush


const backend = new SyncMockBackend({ autoRespond: true });
backend
  .whenGET('http://test.me/api/templates/abc123')
  .respondWithSuccess({ _id: 5, name: 'Test template' });

service.load();

Verify No Pending Requests

const backend = new SyncMockBackend();
backend
  .whenGET('http://test.me/api/templates/abc123')
  .respondWithSuccess({ _id: 5, name: 'Test template' });
service.load();
//backend.flushNext();
backend.verifyNoPendingRequests();

It will throw an error because there is an unflushed request.

Verify No Expected Requests

const backend = new SyncMockBackend();
backend
  .whenGET('http://test.me/api/templates/abc123')
  .respondWithSuccess({ _id: 5, name: 'Test template' });
backend
  .whenDELETE('http://test.me/api/templates/abc123')
  .respondWithSuccess({ _id: 5, name: 'Test template' });
service.load();
//backend.delete();
backend.verifyNoExpectedRequests();

It will throw an error because there is an unused expectation. (DELETE)

FAQs

Package last updated on 16 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc