मैं ऐसे घटक का परीक्षण नहीं कर सकता जो अंगुलर 2 में दिनांक पाइप का उपयोग करता है (फैंटॉमजेएस के माध्यम से कर्म का उपयोग करके)। जब मैं कोशिश, मैं मूल अपवाद: ReferenceError: चर नहीं मिली: Intlकोणीय 2 में दिनांक पाइप का उपयोग करके मैं तत्व के प्रतिपादन का परीक्षण कैसे कर सकता हूं?
यहाँ अपने पूरे कल्पना फ़ाइल है:
import { provide, PLATFORM_PIPES } from '@angular/core';
import { DatePipe } from '@angular/common';
import { addProviders, async, inject } from '@angular/core/testing';
import { Post, PostComponent, PostHtmlComponent } from './';
import { usingComponentFixture } from '../../test-helpers';
describe('Component: Post',() => {
beforeEach(() => {
provide(PLATFORM_PIPES, {useValue: DatePipe, multi: true });
addProviders([PostComponent, PostHtmlComponent, ]);
});
it('should render an h1 tag with text matching the post title',
usingComponentFixture(PostComponent, fixture => {
let component = <PostComponent>fixture.componentInstance;
let element = fixture.nativeElement;
component.post = <Post>{ title: 'Hello', publishedOn: new Date('8/5/2016') };
fixture.detectChanges();
expect(element.querySelector('.blog-post-header h1').innerText).toBe('Hello');
})
);
});
और इस घटक टेम्पलेट है:
<div class="col-lg-8 col-md-7 col-sm-6">
<h1>{{post.title}}</h1>
<p class="lead">{{post.publishedOn | date:'fullDate'}}</p>
</div>
'' 'आयात 'intl/स्थान-डाटा/jsonp/en-us.js '; '' 'का उपयोग कहीं और से कॉपी करने के बजाय किया जा सकता है। –
क्या एक ही मुद्दे की सलाह है लेकिन कोणीय जेएस 1? –