jasmine

React Enzyme find second (or nth) node

我的梦境 提交于 2020-04-07 11:19:52
问题 I'm testing a React component with Jasmine Enzyme shallow rendering. Simplified here for the purposes of this question... function MyOuterComponent() { return ( <div> ... <MyInnerComponent title="Hello" /> ... <MyInnerComponent title="Good-bye" /> ... </div> ) } MyOuterComponent has 2 instances of MyInnerComponent and I'd like to test the props on each one. The first one I know how to test. I use find with first ... expect(component.find('MyInnerComponent').first()).toHaveProp('title', 'Hello

植物:迎春花

試著忘記壹切 提交于 2020-04-06 01:54:01
ylbtech-植物:迎春花 迎春花(学名: Jasminum nudiflorum Lindl. ):别名 迎春、 黄素馨 、金腰带 ,落叶 灌木 丛生。株高30-500厘米。小枝细长直立或拱形下垂,呈纷披状。3小叶复叶交互对生,叶卵形至矩圆形。花单生在去年生的枝条上,先于叶开放,有清香,金黄色,外染红晕,花期2-4月。因其在百花之中开花最早,花后即迎来百花齐放的春天而得名。 迎春花与 梅花 、 水仙 和 山茶花 统称为“雪中四友” ,是中国常见的花卉之一。迎春花不仅 花色端庄秀丽,气质非凡,具有不畏寒威,不择风土,适应性强的特 点,历来为人们所喜爱。迎春花栽培历史1000余年,唐代 白居易 诗《代迎春花召刘郎中》以及宋代 韩琦 《中书东厅迎春》和明代周文华撰《 汝南圃史 》均有记载,迎春花现在为 河南省 鹤壁市 的市花 。 1. 返回顶部 1、 中文学名:迎春花 拉丁学名: Jasminum nudiflorum Lindl. 别 称:小黄花、金腰带、黄梅、清明花 界:植物界 门: 被子植物门 纲: 双子叶植物纲 亚 纲: 合瓣花亚纲 目: 捩花目 亚 目:木樨亚目 科: 木犀科 亚 科: 素馨亚科 属: 素馨属 种:迎春花 命名者及年代:Lindl., 1846 英文名称:Winter Jasmine 目录 1 形态特征 2 生长习性 3 地理分布 4 繁殖方法 5 栽培技术

基于jQuery UI Autocomplete的AngularJS 指令(directive)扩展

我是研究僧i 提交于 2020-03-28 06:47:24
在前几篇随笔简单介绍了 AngularJS ,在 AngularJS 指令( directive )是重要的概念,主要负责了很大部分的组建样式交互。在前面介绍过 directive 需要预先的模板编译在返回一个 link 的函数,注册行为事件交互等等。在这里不多说了,关于指令的介绍将在后续一并补上。在这里我们先看一个利用 jQuery UI 组件开发的 AngularJS Autocomplete 指令。 代码: jsfiddle在线测试 Directive: 1 var oldSuggest = jQuery.ui.autocomplete.prototype._suggest; 2 jQuery.ui.autocomplete.prototype._suggest = function (items) { 3 var itemsArray = items; 4 if ( this .options.maxItems && this .options.maxItems > 0) { 5 itemsArray = items.slice(0, this .options.maxItems); 6 } 7 oldSuggest.call( this , itemsArray); 8 }; 9 10 var autocomplete = function () { 11 var

How to write a unit test for an async method?

瘦欲@ 提交于 2020-03-25 18:21:13
问题 I have the following test code: import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {inject, TestBed} from '@angular/core/testing'; import {AviorBackendService} from './avior-backend.service'; describe('AviorBackendService', () => { beforeEach(() => TestBed.configureTestingModule({ imports: [HttpClientTestingModule], providers: [AviorBackendService], })); it('should be created', () => { const service: AviorBackendService = TestBed.get

Angular 7 testing retryWhen with mock http requests fails to actually retry

做~自己de王妃 提交于 2020-03-20 16:03:05
问题 I have the following interceptor that tries to use a OAuth refresh_token whenever any 401 (error) response is obtained. Basically a refresh token is obtained on the first 401 request and after it is obtained, the code waits 2,5 seconds. In most cases the second request will not trigger an error, but if it does (token couldn't be refreshed or whatever), the user is redirect to the login page. export class RefreshAuthenticationInterceptor implements HttpInterceptor { constructor( private router

Protractor/Jasmine Conditional Test Cases

梦想的初衷 提交于 2020-03-18 05:38:38
问题 Related to this question: How can I create conditional test cases using Protractor? -- I'm curious whether there is a legitimate (documented) answer to these scenarios, because I can't get a straight answer. While the ignore solution posted in the linked question works, stylistically I'm not a fan of it. At first glance it just looks like you're ignoring/skipping the spec. Additionally, I asked this question on Gitter - Is the following code bad practice? if(questionAnswer == "Yes") { it(

How to mock window.location.href with Jest + Vuejs?

泪湿孤枕 提交于 2020-03-17 05:35:04
问题 Currently, I am implementing unit test for my project and there is a file that contained window.location.href . I want to mock this to test and here is my sample code: it("method A should work correctly", () => { const url = "http://dummy.com"; Object.defineProperty(window.location, "href", { value: url, writable: true }); const data = { id: "123", name: null }; window.location.href = url; wrapper.vm.methodA(data); expect(window.location.href).toEqual(url); }); But I get this error: TypeError

Type assertion using the '<>' is forbidden,use 'as' instead?

青春壹個敷衍的年華 提交于 2020-03-16 09:18:37
问题 I have the following test case in my spec, it (should create,()=>{ const url = (<jasmine.spy> http.get).calls.args(0)[0] expect(url).toBe('/api/get') }); When I run it, I am getting the following lint error. Type assertion using the '<>' is forbidden, use as instead? Can anyone please suggest help. 回答1: From Type Assertion. Type assertions as foo vs. <foo> Originally the syntax that was added was <foo> . This is demonstrated below: var foo: any; var bar = <string> foo; // bar is now of type

How can I email reports generated from 'protractor-jasmine2-html-reporter' to stakeholders after successful test execution.

巧了我就是萌 提交于 2020-03-05 05:57:11
问题 I have a config file as below: var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter'); exports.config = { directConnect: true, onPrepare: function() { jasmine.getEnv().addReporter( new Jasmine2HtmlReporter({ savePath: './test/reports/', screenshotsFolder: 'images', }) ); }, multiCapabilities: [ { 'browserName': 'chrome', }], framework: 'jasmine', specs: ['zoo_spec.js'], jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000 } }; My question is is there any code i

How to test a service function in Angular that returns an $http request

旧时模样 提交于 2020-03-02 15:41:48
问题 I have a simple service that makes an $http request angular.module('rootApp') .factory('projectService', ['$http', function ($http) { return { getProject: getProject, getProjects: getProjects, }; function getProject(id) { return $http.get('/projects.json/', { 'params': { 'id': id }}); } }]); I'm wondering how can I test this simply and cleanly? Here's what I have so far in my test. describe("Root App", function () { var mockGetProjectResponse = null, $httpBackend = null; beforeEach(module(