本文介绍了预期'> '等于'> '在茉莉花的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试jQuery终端,但我收到错误:

I'm testing jQuery terminal and I got error:

Expected '> ' to equal '> '.

$(function() {
    describe('Terminal plugin', function() {
        describe('terminal create terminal destroy', function() {
            var term = $('<div id="term"></div>').appendTo('body').terminal();
            it('should have default prompt', function() {
                var prompt = term.find('.prompt');
                expect(prompt.html()).toEqual("<span>&gt;&nbsp;</span>");
                expect(prompt.text()).toEqual('> ');
            });
        });
    });
});

它们是相同的值我只需将其复制到控制台并将替换为等于 == === 并返回 true

they are same value I just copy it into console and replace to equal by == or === and it return true.

推荐答案

& nbsp; 是不是常规空间,所以& gt;& nbsp;>是不等价。

&nbsp; is not a "regular" space, so "&gt;&nbsp;" and "> " are not equivalent.

相反,请尝试 expect(prompt.text())。toEqual('> \ xA0'),这是一个非破坏空间的十六进制代码(这比在那里放一个实际的非破坏空间更好!)

Instead, try expect(prompt.text()).toEqual('>\xA0'), that being the hex code for a non-breaking space (it's a better idea than putting an actual non-breaking space in there!)

这篇关于预期'&gt; '等于'&gt; '在茉莉花的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 06:00