How to use normalize method in Best

Best JavaScript code snippet using best

NormalizeRangeTest.js

Source:NormalizeRangeTest.js Github

copy

Full Screen

...39 var ec = Hierarchy.follow(Element.fromDom(viewBlock.get()), endPath).getOrDie();40 var rng = document.createRange();41 rng.setStart(sc.dom(), startOffset);42 rng.setEnd(ec.dom(), endOffset);43 return NormalizeRange.normalize(new DOMUtils(document, { root_element: viewBlock.get() }), rng);44 });45 };46 var cAssertRange = function (startPath, startOffset, endPath, endOffset) {47 return Chain.op(function (range) {48 assertRange(viewBlock.get(), range, startPath, startOffset, endPath, endOffset);49 });50 };51 var cAssertRangeNone = Chain.op(function (range) {52 Assertions.assertEq('Should be none', true, range.isNone());53 });54 viewBlock.attach();55 Pipeline.async({}, [56 Logger.t('Non normalize non collapsed selections', GeneralSteps.sequence([57 Logger.t('Should not normalize on indexed selected at root level', Chain.asStep(viewBlock, [58 cSetHtml('<input>'),59 cNormalizeRange([], 0, [], 1),60 cAssertRangeNone61 ])),62 Logger.t('Should not normalize if selection is around a caret container', Chain.asStep(viewBlock, [63 cSetHtml('<p data-mce-caret="before">b</p>'),64 cNormalizeRange([], 0, [], 1),65 cAssertRangeNone66 ])),67 Logger.t('Should not normalize if selection ends after table', Chain.asStep(viewBlock, [68 cSetHtml('<p>a</p><table><tr><td>b</td></tr></table>'),69 cNormalizeRange([0, 0], 0, [], 2),70 cAssertRangeNone71 ])),72 Logger.t('Should not normalize into pre', Chain.asStep(viewBlock, [73 cSetHtml('<pre>a</pre>'),74 cNormalizeRange([], 0, [], 1),75 cAssertRangeNone76 ])),77 Logger.t('Should not normalize to before/after table', Chain.asStep(viewBlock, [78 cSetHtml('<table><tr><td>a</td></tr></table>'),79 cNormalizeRange([], 0, [], 1),80 cAssertRangeNone81 ]))82 ])),83 Logger.t('Non normalize caret positions', GeneralSteps.sequence([84 Logger.t('Should not normalize on a caret at start of text node', Chain.asStep(viewBlock, [85 cSetHtml('<p>a</p>'),86 cNormalizeRange([0, 0], 0, [0, 0], 0),87 cAssertRangeNone88 ])),89 Logger.t('Should not normalize on a caret at middle of text node', Chain.asStep(viewBlock, [90 cSetHtml('<p>a</p>'),91 cNormalizeRange([0, 0], 1, [0, 0], 1),92 cAssertRangeNone93 ])),94 Logger.t('Should not normalize on a caret at end of text node', Chain.asStep(viewBlock, [95 cSetHtml('<p>a</p>'),96 cNormalizeRange([0, 0], 1, [0, 0], 1),97 cAssertRangeNone98 ])),99 Logger.t('Should not normalize on a caret before input', Chain.asStep(viewBlock, [100 cSetHtml('<p><input></p>'),101 cNormalizeRange([0], 0, [0], 0),102 cAssertRangeNone103 ])),104 Logger.t('Should not normalize on a caret between inputs', Chain.asStep(viewBlock, [105 cSetHtml('<p><input><input></p>'),106 cNormalizeRange([0], 1, [0], 1),107 cAssertRangeNone108 ])),109 Logger.t('Should not normalize on a caret after input', Chain.asStep(viewBlock, [110 cSetHtml('<p><input></p>'),111 cNormalizeRange([0], 1, [0], 1),112 cAssertRangeNone113 ])),114 Logger.t('Should not normalize on a caret after image', Chain.asStep(viewBlock, [115 cSetHtml('<p><img src="about: blank"></p>'),116 cNormalizeRange([0], 1, [0], 1),117 cAssertRangeNone118 ])),119 Logger.t('Should not normalize on a caret before image', Chain.asStep(viewBlock, [120 cSetHtml('<p><img src="about: blank"></p>'),121 cNormalizeRange([0], 0, [0], 0),122 cAssertRangeNone123 ])),124 Logger.t('Should not normalize before br', Chain.asStep(viewBlock, [125 cSetHtml('<p><br></p>'),126 cNormalizeRange([0], 0, [0], 0),127 cAssertRangeNone128 ])),129 Logger.t('Should not normalize into previous block with format', Chain.asStep(viewBlock, [130 cSetHtml('<div><p><b>a</b></p>b</p>'),131 cNormalizeRange([0, 1], 0, [0, 1], 0),132 cAssertRangeNone133 ])),134 Logger.t('Should not normalize into previous format inline with input', Chain.asStep(viewBlock, [135 cSetHtml('<p><b><input></b>b</p>'),136 cNormalizeRange([0, 1], 0, [0, 1], 0),137 cAssertRangeNone138 ])),139 Logger.t('Should not normalize into previous cef inline', Chain.asStep(viewBlock, [140 cSetHtml('<p><b contenteditable="false">a</b>b</p>'),141 cNormalizeRange([0, 1], 0, [0, 1], 0),142 cAssertRangeNone143 ])),144 Logger.t('Should not normalize into cef block', Chain.asStep(viewBlock, [145 cSetHtml('<p contenteditable="false">a</p>'),146 cNormalizeRange([], 0, [], 0),147 cAssertRangeNone148 ])),149 Logger.t('Should not normalize into previous anchor inline', Chain.asStep(viewBlock, [150 cSetHtml('<p><a href="#">a</a>b</p>'),151 cNormalizeRange([0, 1], 0, [0, 1], 0),152 cAssertRangeNone153 ])),154 Logger.t('Should not normalize out of a caret container', Chain.asStep(viewBlock, [155 cSetHtml('<p><b>a</b><span data-mce-caret="before">b</span></p>'),156 cNormalizeRange([0, 1, 0], 0, [0, 1, 0], 0),157 cAssertRangeNone158 ])),159 Logger.t('Should not normalize out of a caret container', Chain.asStep(viewBlock, [160 cSetHtml('<p><b>a</b>' + Zwsp.ZWSP + '</p>'),161 cNormalizeRange([0, 1], 0, [0, 1], 0),162 cAssertRangeNone163 ])),164 Logger.t('Should not normalize when caret is at start of text node', Chain.asStep(viewBlock, [165 cSetHtml('a'),166 cNormalizeRange([0], 0, [0], 0),167 cAssertRangeNone168 ])),169 Logger.t('Should not normalize when caret is at end of text node', Chain.asStep(viewBlock, [170 cSetHtml('a'),171 cNormalizeRange([0], 1, [0], 1),172 cAssertRangeNone173 ])),174 Logger.t('Should not normalize when caret is at middle of text node', Chain.asStep(viewBlock, [175 cSetHtml('ab'),176 cNormalizeRange([0], 1, [0], 1),177 cAssertRangeNone178 ])),179 Logger.t('Should not normalize when caret is before text node', Chain.asStep(viewBlock, [180 cSetHtml('a'),181 cNormalizeRange([], 0, [], 0),182 cAssertRangeNone183 ])),184 Logger.t('Should not normalize when caret is after text node', Chain.asStep(viewBlock, [185 cSetHtml('a'),186 cNormalizeRange([], 1, [], 1),187 cAssertRangeNone188 ])),189 Logger.t('Should not normalize into inline elements if target inline pos is a br', Chain.asStep(viewBlock, [190 cSetHtml('<p><i><b><br /></b></i><br /></p>'),191 cNormalizeRange([0], 1, [0], 1),192 cAssertRangeNone193 ])),194 Logger.t('Should not normalize from after double br', Chain.asStep(viewBlock, [195 cSetHtml('<p>a<br /><br /></p>'),196 cNormalizeRange([0], 3, [0], 3),197 cAssertRangeNone198 ])),199 Logger.t('Should not normalize into first text node', Chain.asStep(viewBlock, [200 cSetHtml('a<b>b</b>c'),201 cNormalizeRange([], 0, [], 0),202 cAssertRangeNone203 ])),204 Logger.t('Should not normalize into last text node', Chain.asStep(viewBlock, [205 cSetHtml('a<b>b</b>c'),206 cNormalizeRange([], 3, [], 3),207 cAssertRangeNone208 ]))209 ])),210 Logger.t('Normalize caret positions', GeneralSteps.sequence([211 Logger.t('Should normalize caret and lean left from text node into previous inline element text node', Chain.asStep(viewBlock, [212 cSetHtml('<p><b>a</b>b</p>'),213 cNormalizeRange([0, 1], 0, [0, 1], 0),214 cAssertRange([0, 0, 0], 1, [0, 0, 0], 1)215 ])),216 Logger.t('Should normalize caret and lean left from text node into previous text node', Chain.asStep(viewBlock, [217 cSetHtml('<p>a<b>b</b></p>'),218 cNormalizeRange([0, 1, 0], 0, [0, 1, 0], 0),219 cAssertRange([0, 0], 1, [0, 0], 1)220 ])),221 Logger.t('Should normalize caret and lean left from inline element text node into previous inline element text node', Chain.asStep(viewBlock, [222 cSetHtml('<p><b>a</b><i>b</i></p>'),223 cNormalizeRange([0, 1, 0], 0, [0, 1, 0], 0),224 cAssertRange([0, 0, 0], 1, [0, 0, 0], 1)225 ])),226 Logger.t('Should normalize caret and lean left from before br in inline element into previous inline element text node', Chain.asStep(viewBlock, [227 cSetHtml('<p><b>a</b><i><br></i></p>'),228 cNormalizeRange([0, 1], 0, [0, 1], 0),229 cAssertRange([0, 0, 0], 1, [0, 0, 0], 1)230 ])),231 Logger.t('Should normalize on a caret between blocks', Chain.asStep(viewBlock, [232 cSetHtml('<p>a</p><p>b</p>'),233 cNormalizeRange([], 1, [], 1),234 cAssertRange([1, 0], 0, [1, 0], 0)235 ])),236 Logger.t('Should normalize from after br to before br', Chain.asStep(viewBlock, [237 cSetHtml('<p><br /></p>'),238 cNormalizeRange([0], 1, [0], 1),239 cAssertRange([0], 0, [0], 0)240 ])),241 Logger.t('Should normalize from after br to before br', Chain.asStep(viewBlock, [242 cSetHtml('<p>a<br /></p>'),243 cNormalizeRange([0], 1, [0], 1),244 cAssertRange([0, 0], 1, [0, 0], 1)245 ])),246 Logger.t('Should normalize before paragraph', Chain.asStep(viewBlock, [247 cSetHtml('<p>a</p>'),248 cNormalizeRange([], 0, [], 0),249 cAssertRange([0, 0], 0, [0, 0], 0)250 ])),251 Logger.t('Should normalize after paragraph', Chain.asStep(viewBlock, [252 cSetHtml('<p>a</p>'),253 cNormalizeRange([], 1, [], 1),254 cAssertRange([0, 0], 1, [0, 0], 1)255 ])),256 Logger.t('Should normalize into caret container', Chain.asStep(viewBlock, [257 cSetHtml('<p><span id="_mce_caret">' + Zwsp.ZWSP + '</span><br /></p>'),258 cNormalizeRange([0], 1, [0], 1),259 cAssertRange([0, 0, 0], 1, [0, 0, 0], 1)260 ])),261 Logger.t('Should normalize into empty inline element before', Chain.asStep(viewBlock, [262 cSetHtml('<p><i><b></b></i><br /></p>'),263 cNormalizeRange([0], 1, [0], 1),264 cAssertRange([0, 0, 0], 0, [0, 0, 0], 0)265 ]))266 ])),267 Logger.t('Normalize expanded selections', GeneralSteps.sequence([268 Logger.t('Should normalize to before/after image', Chain.asStep(viewBlock, [269 cSetHtml('<p><img src="about:blank "></p>'),270 cNormalizeRange([], 0, [], 1),271 cAssertRange([0], 0, [0], 1)272 ])),273 Logger.t('Should normalize to text node in p', Chain.asStep(viewBlock, [274 cSetHtml('<p>a</p>'),275 cNormalizeRange([], 0, [], 1),276 cAssertRange([0, 0], 0, [0, 0], 1)277 ])),278 Logger.t('Should normalize to text node in middle p', Chain.asStep(viewBlock, [279 cSetHtml('<p>a</p><p>b</p><p>c</p>'),280 cNormalizeRange([], 1, [], 2),281 cAssertRange([1, 0], 0, [1, 0], 1)282 ])),283 Logger.t('Should normalize start from end of inline to start of next inline element', Chain.asStep(viewBlock, [284 cSetHtml('<p><b>a</b><i>b</i></p>'),285 cNormalizeRange([0, 0, 0], 1, [0, 1, 0], 1),286 cAssertRange([0, 1, 0], 0, [0, 1, 0], 1)287 ]))288 ])),289 Logger.t('Normalize on document', Step.sync(function () {290 var doc = document.implementation.createHTMLDocument('');291 var rng = document.createRange();292 var dom = new DOMUtils(doc, { root_element: doc.body });293 doc.body.innerHTML = '<p>a</p>';294 rng.setStart(document, 0);295 rng.setEnd(document, 0);296 var normRng = NormalizeRange.normalize(dom, rng);297 assertRange(doc.body, normRng, [0, 0], 0, [0, 0], 0);298 }))299 ], function () {300 viewBlock.detach();301 success();302 }, failure);303 }...

Full Screen

Full Screen

normalizeColor-test.js

Source:normalizeColor-test.js Github

copy

Full Screen

1/**2 * Copyright (c) 2015-present, Facebook, Inc.3 * All rights reserved.4 *5 * This source code is licensed under the BSD-style license found in the6 * LICENSE file in the root directory of this source tree. An additional grant7 * of patent rights can be found in the PATENTS file in the same directory.8 */9'use strict';10var normalizeColor = require('normalizeColor');11describe('normalizeColor', function() {12 it('should accept only spec compliant colors', function() {13 expect(normalizeColor('#abc')).not.toBe(null);14 expect(normalizeColor('#abcd')).not.toBe(null);15 expect(normalizeColor('#abcdef')).not.toBe(null);16 expect(normalizeColor('#abcdef01')).not.toBe(null);17 expect(normalizeColor('rgb(1,2,3)')).not.toBe(null);18 expect(normalizeColor('rgb(1, 2, 3)')).not.toBe(null);19 expect(normalizeColor('rgb( 1 , 2 , 3 )')).not.toBe(null);20 expect(normalizeColor('rgb(-1, -2, -3)')).not.toBe(null);21 expect(normalizeColor('rgba(0, 0, 0, 1)')).not.toBe(null);22 expect(normalizeColor(0x01234567 + 0.5)).toBe(null);23 expect(normalizeColor(-1)).toBe(null);24 expect(normalizeColor(0xffffffff + 1)).toBe(null);25 });26 it('should temporarly accept floating point values for rgb', function() {27 expect(normalizeColor('rgb(1.1, 2.1, 3.1)')).toBe(0x010203ff);28 expect(normalizeColor('rgba(1.1, 2.1, 3.1, 1.0)')).toBe(0x010203ff);29 });30 it('should refuse non spec compliant colors', function() {31 expect(normalizeColor('#00gg00')).toBe(null);32 expect(normalizeColor('rgb(1, 2, 3,)')).toBe(null);33 expect(normalizeColor('rgb(1, 2, 3')).toBe(null);34 // Used to be accepted by normalizeColor35 expect(normalizeColor('abc')).toBe(null);36 expect(normalizeColor(' #abc ')).toBe(null);37 expect(normalizeColor('##abc')).toBe(null);38 expect(normalizeColor('rgb 255 0 0')).toBe(null);39 expect(normalizeColor('RGBA(0, 1, 2)')).toBe(null);40 expect(normalizeColor('rgb (0, 1, 2)')).toBe(null);41 expect(normalizeColor('hsv(0, 1, 2)')).toBe(null);42 expect(normalizeColor({r: 10, g: 10, b: 10})).toBe(null);43 expect(normalizeColor('hsl(1%, 2, 3)')).toBe(null);44 expect(normalizeColor('rgb(1%, 2%, 3%)')).toBe(null);45 });46 it('should handle hex6 properly', function() {47 expect(normalizeColor('#000000')).toBe(0x000000ff);48 expect(normalizeColor('#ffffff')).toBe(0xffffffff);49 expect(normalizeColor('#ff00ff')).toBe(0xff00ffff);50 expect(normalizeColor('#abcdef')).toBe(0xabcdefff);51 expect(normalizeColor('#012345')).toBe(0x012345ff);52 });53 it('should handle hex3 properly', function() {54 expect(normalizeColor('#000')).toBe(0x000000ff);55 expect(normalizeColor('#fff')).toBe(0xffffffff);56 expect(normalizeColor('#f0f')).toBe(0xff00ffff);57 });58 it('should handle hex8 properly', function() {59 expect(normalizeColor('#00000000')).toBe(0x00000000);60 expect(normalizeColor('#ffffffff')).toBe(0xffffffff);61 expect(normalizeColor('#ffff00ff')).toBe(0xffff00ff);62 expect(normalizeColor('#abcdef01')).toBe(0xabcdef01);63 expect(normalizeColor('#01234567')).toBe(0x01234567);64 });65 it('should handle rgb properly', function() {66 expect(normalizeColor('rgb(0, 0, 0)')).toBe(0x000000ff);67 expect(normalizeColor('rgb(-1, -2, -3)')).toBe(0x000000ff);68 expect(normalizeColor('rgb(0, 0, 255)')).toBe(0x0000ffff);69 expect(normalizeColor('rgb(100, 15, 69)')).toBe(0x640f45ff);70 expect(normalizeColor('rgb(255, 255, 255)')).toBe(0xffffffff);71 expect(normalizeColor('rgb(256, 256, 256)')).toBe(0xffffffff);72 });73 it('should handle rgba properly', function() {74 expect(normalizeColor('rgba(0, 0, 0, 0.0)')).toBe(0x00000000);75 expect(normalizeColor('rgba(0, 0, 0, 0)')).toBe(0x00000000);76 expect(normalizeColor('rgba(0, 0, 0, -0.5)')).toBe(0x00000000);77 expect(normalizeColor('rgba(0, 0, 0, 1.0)')).toBe(0x000000ff);78 expect(normalizeColor('rgba(0, 0, 0, 1)')).toBe(0x000000ff);79 expect(normalizeColor('rgba(0, 0, 0, 1.5)')).toBe(0x000000ff);80 expect(normalizeColor('rgba(100, 15, 69, 0.5)')).toBe(0x640f4580);81 });82 it('should handle hsl properly', function() {83 expect(normalizeColor('hsl(0, 0%, 0%)')).toBe(0x000000ff);84 expect(normalizeColor('hsl(360, 100%, 100%)')).toBe(0xffffffff);85 expect(normalizeColor('hsl(180, 50%, 50%)')).toBe(0x40bfbfff);86 expect(normalizeColor('hsl(540, 50%, 50%)')).toBe(0x40bfbfff);87 expect(normalizeColor('hsl(70, 25%, 75%)')).toBe(0xcacfafff);88 expect(normalizeColor('hsl(70, 100%, 75%)')).toBe(0xeaff80ff);89 expect(normalizeColor('hsl(70, 110%, 75%)')).toBe(0xeaff80ff);90 expect(normalizeColor('hsl(70, 0%, 75%)')).toBe(0xbfbfbfff);91 expect(normalizeColor('hsl(70, -10%, 75%)')).toBe(0xbfbfbfff);92 });93 it('should handle hsla properly', function() {94 expect(normalizeColor('hsla(0, 0%, 0%, 0)')).toBe(0x00000000);95 expect(normalizeColor('hsla(360, 100%, 100%, 1)')).toBe(0xffffffff);96 expect(normalizeColor('hsla(360, 100%, 100%, 0)')).toBe(0xffffff00);97 expect(normalizeColor('hsla(180, 50%, 50%, 0.2)')).toBe(0x40bfbf33);98 });99 it('should handle named colors properly', function() {100 expect(normalizeColor('red')).toBe(0xff0000ff);101 expect(normalizeColor('transparent')).toBe(0x00000000);102 expect(normalizeColor('peachpuff')).toBe(0xffdab9ff);103 });104 it('should handle number colors properly', function() {105 expect(normalizeColor(0x00000000)).toBe(0x00000000);106 expect(normalizeColor(0xff0000ff)).toBe(0xff0000ff);107 expect(normalizeColor(0xffffffff)).toBe(0xffffffff);108 expect(normalizeColor(0x01234567)).toBe(0x01234567);109 });110 it('should return the same color when it\'s already normalized', function() {111 const normalizedColor = normalizeColor('red') || 0;112 expect(normalizeColor(normalizedColor)).toBe(normalizedColor);113 });...

Full Screen

Full Screen

jquery.sap.unicode.qunit.js

Source:jquery.sap.unicode.qunit.js Github

copy

Full Screen

...46 QUnit.test("reference data", function(assert) {47 assert.expect(8);48 jQuery.each(aData, function(i, o) {49 assert.equal(toCharCodes(o.string), o.representation, "\"" + o.form + "\"" + " string is valid");50 assert.equal(o.string.normalize(o.form), o.string, "\"" + o.form + "\"" + " string is \"" + o.form + "\"" );51 });52 });53 jQuery.each(aData, function(i, o) {54 QUnit.module(o.form, {55 beforeEach: function() {56 this.s = aData[0].string + aData[1].string + aData[2].string + aData[3].string;57 }58 });59 // ref: http://unicode.org/reports/tr15/#Design_Goals60 QUnit.test("chaining", function(assert) {61 o.compatible ? assert.expect(6) : assert.expect(2);62 // primitive value of the normalized string as reference63 var sRef = this.s.normalize(o.form).valueOf();64 assert.equal(this.s.normalize("NFC").normalize(o.form), sRef, "\"NFC\"");65 assert.equal(this.s.normalize("NFD").normalize(o.form), sRef, "\"NFD\"");66 if (o.compatible) {67 // compatibility normalizations68 assert.equal(this.s.normalize("NFKC").normalize(o.form), sRef, "\"NFKC\"");69 assert.equal(this.s.normalize("NFKD").normalize(o.form), sRef, "\"NFKD\"");70 // and corresponding standard normalization71 assert.equal(this.s.normalize("NFKC").normalize(o.form.replace("K","")), sRef, "\"NFKC\"");72 assert.equal(this.s.normalize("NFKD").normalize(o.form.replace("K","")), sRef, "\"NFKD\"");73 }74 });75 });76 }77 // do not perform tests on mobiles without native support78 if (!Device.browser.mobile || String.prototype.normalize) {79 QUnit.module("Quick check NFC", {80 beforeEach: function() {81 // blind test, no relevant characters82 this.sBlind = "ABC";83 // some random combined characters84 this.sSomething = "Améliè";85 // all forms different character86 this.sNFC = "\u1E9B\u0323";87 this.sNFC = "\u1E9B\u0323";88 this.sNFD = "\u017F\u0323\u0307";89 this.sNFKC = "\u1E69";90 this.sNFKD = "\u0073\u0323\u0307";91 this.s = this.sNFC + this.sNFD + this.sNFKC + this.sNFKD;92 },93 afterEach: function() {}94 });95 QUnit.test("verify test string", function(assert) {96 assert.equal(this.sBlind, this.sBlind.normalize("NFC"), "NFC verified");97 assert.equal(this.sSomething, this.sSomething.normalize("NFC"), "NFC verified");98 assert.equal(this.sNFC, this.sNFC.normalize("NFC"), "NFC verified");99 assert.equal(this.sNFD, this.sNFD.normalize("NFD"), "NFD verified");100 assert.equal(this.sNFKC, this.sNFKC.normalize("NFKC"), "NFKC verified");101 assert.equal(this.sNFKD, this.sNFKD.normalize("NFKD"), "NFKD verified");102 assert.notEqual(this.s, this.s.normalize("NFC"), "not NFC verified");103 assert.notEqual(this.s, this.s.normalize("NFD"), "not NFD verified");104 assert.notEqual(this.s, this.s.normalize("NFKC"), "not NFKC verified");105 assert.notEqual(this.s, this.s.normalize("NFKD"), "not NFKD verified");106 assert.equal(this.sNFC + this.sNFC + this.sNFKC + this.sNFKC, this.s.normalize("NFC"), "NFC concatenation verified");107 assert.equal(this.sNFD + this.sNFD + this.sNFKD + this.sNFKD, this.s.normalize("NFD"), "NFD concatenation verified");108 assert.equal(this.sNFKC + this.sNFKC + this.sNFKC + this.sNFKC, this.s.normalize("NFKC"), "NFKC concatenation verified");109 assert.equal(this.sNFKD + this.sNFKD + this.sNFKD + this.sNFKD, this.s.normalize("NFKD"), "NFKD concatenation verified");110 });111 QUnit.test("isStringNFC", function(assert) {112 assert.ok(jQuery.sap.isStringNFC("ABC"), "NFC is NFC");113 assert.ok(jQuery.sap.isStringNFC("Améliè"), "NFC is NFC");114 assert.ok(!jQuery.sap.isStringNFC(this.sNFC) || jQuery.sap.isStringNFC(this.sNFC), "NFC maybe NFC");115 assert.ok(!jQuery.sap.isStringNFC(this.sNFD), "NFD is not NFC");116 assert.ok(jQuery.sap.isStringNFC(this.sNFKC), "NFKC is also NFC");117 assert.ok(!jQuery.sap.isStringNFC(this.sNFKD), "NFKD is not NFC");118 assert.ok(!jQuery.sap.isStringNFC(this.s), "concatenation is not NFC");119 });120 }...

Full Screen

Full Screen

normalize-generateddata.js

Source:normalize-generateddata.js Github

copy

Full Screen

...23 var nfdStr = stringify(test.NFD);24 var nfkcStr = stringify(test.NFKC);25 var nfkdStr = stringify(test.NFKD);26 /* NFC */27 assertEq(source.normalize(), NFC, "NFC of " + sourceStr);28 assertEq(NFC.normalize(), NFC, "NFC of " + nfcStr);29 assertEq(NFD.normalize(), NFC, "NFC of " + nfdStr);30 assertEq(NFKC.normalize(), NFKC, "NFC of " + nfkcStr);31 assertEq(NFKD.normalize(), NFKC, "NFC of " + nfkdStr);32 assertEq(source.normalize(undefined), NFC, "NFC of " + sourceStr);33 assertEq(NFC.normalize(undefined), NFC, "NFC of " + nfcStr);34 assertEq(NFD.normalize(undefined), NFC, "NFC of " + nfdStr);35 assertEq(NFKC.normalize(undefined), NFKC, "NFC of " + nfkcStr);36 assertEq(NFKD.normalize(undefined), NFKC, "NFC of " + nfkdStr);37 assertEq(source.normalize("NFC"), NFC, "NFC of " + sourceStr);38 assertEq(NFC.normalize("NFC"), NFC, "NFC of " + nfcStr);39 assertEq(NFD.normalize("NFC"), NFC, "NFC of " + nfdStr);40 assertEq(NFKC.normalize("NFC"), NFKC, "NFC of " + nfkcStr);41 assertEq(NFKD.normalize("NFC"), NFKC, "NFC of " + nfkdStr);42 /* NFD */43 assertEq(source.normalize("NFD"), NFD, "NFD of " + sourceStr);44 assertEq(NFC.normalize("NFD"), NFD, "NFD of " + nfcStr);45 assertEq(NFD.normalize("NFD"), NFD, "NFD of " + nfdStr);46 assertEq(NFKC.normalize("NFD"), NFKD, "NFD of " + nfkcStr);47 assertEq(NFKD.normalize("NFD"), NFKD, "NFD of " + nfkdStr);48 /* NFKC */49 assertEq(source.normalize("NFKC"), NFKC, "NFKC of " + sourceStr);50 assertEq(NFC.normalize("NFKC"), NFKC, "NFKC of " + nfcStr);51 assertEq(NFD.normalize("NFKC"), NFKC, "NFKC of " + nfdStr);52 assertEq(NFKC.normalize("NFKC"), NFKC, "NFKC of " + nfkcStr);53 assertEq(NFKD.normalize("NFKC"), NFKC, "NFKC of " + nfkdStr);54 /* NFKD */55 assertEq(source.normalize("NFKD"), NFKD, "NFKD of " + sourceStr);56 assertEq(NFC.normalize("NFKD"), NFKD, "NFKD of " + nfcStr);57 assertEq(NFD.normalize("NFKD"), NFKD, "NFKD of " + nfdStr);58 assertEq(NFKC.normalize("NFKD"), NFKD, "NFKD of " + nfkcStr);59 assertEq(NFKD.normalize("NFKD"), NFKD, "NFKD of " + nfkdStr);60}61for (var test0 of tests_part0) {62 runTest(test0);63}64var part1 = new Set();65for (var test1 of tests_part1) {66 part1.add(test1.source[0]);67 runTest(test1);68}69for (var test2 of tests_part2) {70 runTest(test2);71}72for (var test3 of tests_part3) {73 runTest(test3);74}75/* not listed in Part 1 */76for (var x = 0; x <= 0x2FFFF; x++) {77 if (part1.has(x)) {78 continue;79 }80 var xstr = x.toString(16);81 var c = String.fromCodePoint(x);82 assertEq(c.normalize(), c, "NFC of " + xstr);83 assertEq(c.normalize(undefined), c, "NFC of " + xstr);84 assertEq(c.normalize("NFC"), c, "NFC of " + xstr);85 assertEq(c.normalize("NFD"), c, "NFD of " + xstr);86 assertEq(c.normalize("NFKC"), c, "NFKC of " + xstr);87 assertEq(c.normalize("NFKD"), c, "NFKD of " + xstr);88}89var myobj = {toString : (function () "a\u0301"), normalize : String.prototype.normalize};90assertEq(myobj.normalize(), "\u00E1");91assertThrowsInstanceOf(function() {92 "abc".normalize("NFE");93 }, RangeError,94 "String.prototype.normalize should raise RangeError on invalid form");95assertEq("".normalize(), "");96/* JSRope test */97var a = "";98var b = "";99for (var i = 0; i < 100; i++) {100 a += "\u0100";101 b += "\u0041\u0304";102}103assertEq(a.normalize("NFD"), b);104/******************************************************************************/105if (typeof reportCompare === "function")106 reportCompare(true, true);...

Full Screen

Full Screen

test-path-normalize.js

Source:test-path-normalize.js Github

copy

Full Screen

1'use strict';2require('../common');3const assert = require('assert');4const path = require('path');5assert.strictEqual(path.win32.normalize('./fixtures///b/../b/c.js'),6 'fixtures\\b\\c.js');7assert.strictEqual(path.win32.normalize('/foo/../../../bar'), '\\bar');8assert.strictEqual(path.win32.normalize('a//b//../b'), 'a\\b');9assert.strictEqual(path.win32.normalize('a//b//./c'), 'a\\b\\c');10assert.strictEqual(path.win32.normalize('a//b//.'), 'a\\b');11assert.strictEqual(path.win32.normalize('//server/share/dir/file.ext'),12 '\\\\server\\share\\dir\\file.ext');13assert.strictEqual(path.win32.normalize('/a/b/c/../../../x/y/z'), '\\x\\y\\z');14assert.strictEqual(path.win32.normalize('C:'), 'C:.');15assert.strictEqual(path.win32.normalize('C:..\\abc'), 'C:..\\abc');16assert.strictEqual(path.win32.normalize('C:..\\..\\abc\\..\\def'),17 'C:..\\..\\def');18assert.strictEqual(path.win32.normalize('C:\\.'), 'C:\\');19assert.strictEqual(path.win32.normalize('file:stream'), 'file:stream');20assert.strictEqual(path.win32.normalize('bar\\foo..\\..\\'), 'bar\\');21assert.strictEqual(path.win32.normalize('bar\\foo..\\..'), 'bar');22assert.strictEqual(path.win32.normalize('bar\\foo..\\..\\baz'), 'bar\\baz');23assert.strictEqual(path.win32.normalize('bar\\foo..\\'), 'bar\\foo..\\');24assert.strictEqual(path.win32.normalize('bar\\foo..'), 'bar\\foo..');25assert.strictEqual(path.win32.normalize('..\\foo..\\..\\..\\bar'),26 '..\\..\\bar');27assert.strictEqual(path.win32.normalize('..\\...\\..\\.\\...\\..\\..\\bar'),28 '..\\..\\bar');29assert.strictEqual(path.win32.normalize('../../../foo/../../../bar'),30 '..\\..\\..\\..\\..\\bar');31assert.strictEqual(path.win32.normalize('../../../foo/../../../bar/../../'),32 '..\\..\\..\\..\\..\\..\\');33assert.strictEqual(34 path.win32.normalize('../foobar/barfoo/foo/../../../bar/../../'),35 '..\\..\\'36);37assert.strictEqual(38 path.win32.normalize('../.../../foobar/../../../bar/../../baz'),39 '..\\..\\..\\..\\baz'40);41assert.strictEqual(path.win32.normalize('foo/bar\\baz'), 'foo\\bar\\baz');42assert.strictEqual(path.posix.normalize('./fixtures///b/../b/c.js'),43 'fixtures/b/c.js');44assert.strictEqual(path.posix.normalize('/foo/../../../bar'), '/bar');45assert.strictEqual(path.posix.normalize('a//b//../b'), 'a/b');46assert.strictEqual(path.posix.normalize('a//b//./c'), 'a/b/c');47assert.strictEqual(path.posix.normalize('a//b//.'), 'a/b');48assert.strictEqual(path.posix.normalize('/a/b/c/../../../x/y/z'), '/x/y/z');49assert.strictEqual(path.posix.normalize('///..//./foo/.//bar'), '/foo/bar');50assert.strictEqual(path.posix.normalize('bar/foo../../'), 'bar/');51assert.strictEqual(path.posix.normalize('bar/foo../..'), 'bar');52assert.strictEqual(path.posix.normalize('bar/foo../../baz'), 'bar/baz');53assert.strictEqual(path.posix.normalize('bar/foo../'), 'bar/foo../');54assert.strictEqual(path.posix.normalize('bar/foo..'), 'bar/foo..');55assert.strictEqual(path.posix.normalize('../foo../../../bar'), '../../bar');56assert.strictEqual(path.posix.normalize('../.../.././.../../../bar'),57 '../../bar');58assert.strictEqual(path.posix.normalize('../../../foo/../../../bar'),59 '../../../../../bar');60assert.strictEqual(path.posix.normalize('../../../foo/../../../bar/../../'),61 '../../../../../../');62assert.strictEqual(63 path.posix.normalize('../foobar/barfoo/foo/../../../bar/../../'),64 '../../'65);66assert.strictEqual(67 path.posix.normalize('../.../../foobar/../../../bar/../../baz'),68 '../../../../baz'69);...

Full Screen

Full Screen

shell.js

Source:shell.js Github

copy

Full Screen

...15 var nfdStr = stringify(test.NFD);16 var nfkcStr = stringify(test.NFKC);17 var nfkdStr = stringify(test.NFKD);18 /* NFC */19 assertEq(source.normalize(), NFC, "NFC of " + sourceStr);20 assertEq(NFC.normalize(), NFC, "NFC of " + nfcStr);21 assertEq(NFD.normalize(), NFC, "NFC of " + nfdStr);22 assertEq(NFKC.normalize(), NFKC, "NFC of " + nfkcStr);23 assertEq(NFKD.normalize(), NFKC, "NFC of " + nfkdStr);24 assertEq(source.normalize(undefined), NFC, "NFC of " + sourceStr);25 assertEq(NFC.normalize(undefined), NFC, "NFC of " + nfcStr);26 assertEq(NFD.normalize(undefined), NFC, "NFC of " + nfdStr);27 assertEq(NFKC.normalize(undefined), NFKC, "NFC of " + nfkcStr);28 assertEq(NFKD.normalize(undefined), NFKC, "NFC of " + nfkdStr);29 assertEq(source.normalize("NFC"), NFC, "NFC of " + sourceStr);30 assertEq(NFC.normalize("NFC"), NFC, "NFC of " + nfcStr);31 assertEq(NFD.normalize("NFC"), NFC, "NFC of " + nfdStr);32 assertEq(NFKC.normalize("NFC"), NFKC, "NFC of " + nfkcStr);33 assertEq(NFKD.normalize("NFC"), NFKC, "NFC of " + nfkdStr);34 /* NFD */35 assertEq(source.normalize("NFD"), NFD, "NFD of " + sourceStr);36 assertEq(NFC.normalize("NFD"), NFD, "NFD of " + nfcStr);37 assertEq(NFD.normalize("NFD"), NFD, "NFD of " + nfdStr);38 assertEq(NFKC.normalize("NFD"), NFKD, "NFD of " + nfkcStr);39 assertEq(NFKD.normalize("NFD"), NFKD, "NFD of " + nfkdStr);40 /* NFKC */41 assertEq(source.normalize("NFKC"), NFKC, "NFKC of " + sourceStr);42 assertEq(NFC.normalize("NFKC"), NFKC, "NFKC of " + nfcStr);43 assertEq(NFD.normalize("NFKC"), NFKC, "NFKC of " + nfdStr);44 assertEq(NFKC.normalize("NFKC"), NFKC, "NFKC of " + nfkcStr);45 assertEq(NFKD.normalize("NFKC"), NFKC, "NFKC of " + nfkdStr);46 /* NFKD */47 assertEq(source.normalize("NFKD"), NFKD, "NFKD of " + sourceStr);48 assertEq(NFC.normalize("NFKD"), NFKD, "NFKD of " + nfcStr);49 assertEq(NFD.normalize("NFKD"), NFKD, "NFKD of " + nfdStr);50 assertEq(NFKC.normalize("NFKD"), NFKD, "NFKD of " + nfkcStr);51 assertEq(NFKD.normalize("NFKD"), NFKD, "NFKD of " + nfkdStr);...

Full Screen

Full Screen

normalize.js

Source:normalize.js Github

copy

Full Screen

...3import {percentile, take} from "../options.js";4import {mapX, mapY} from "./map.js";5export function normalizeX(basis, options) {6 if (arguments.length === 1) ({basis, ...options} = basis);7 return mapX(normalize(basis), options);8}9export function normalizeY(basis, options) {10 if (arguments.length === 1) ({basis, ...options} = basis);11 return mapY(normalize(basis), options);12}13export function normalize(basis) {14 if (basis === undefined) return normalizeFirst;15 if (typeof basis === "function") return normalizeBasis((I, S) => basis(take(S, I)));16 if (/^p\d{2}$/i.test(basis)) return normalizeAccessor(percentile(basis));17 switch (`${basis}`.toLowerCase()) {18 case "deviation": return normalizeDeviation;19 case "first": return normalizeFirst;20 case "last": return normalizeLast;21 case "max": return normalizeMax;22 case "mean": return normalizeMean;23 case "median": return normalizeMedian;24 case "min": return normalizeMin;25 case "sum": return normalizeSum;26 case "extent": return normalizeExtent;27 }...

Full Screen

Full Screen

NormalizePolyfill.qunit.js

Source:NormalizePolyfill.qunit.js Github

copy

Full Screen

1/*global String QUnit */2sap.ui.define(["sap/base/strings/NormalizePolyfill"], function(normalizePolyfill) {3 "use strict";4 QUnit.module("NormalizePolyfill", {5 beforeEach: function () {6 this.fnNormalize = String.prototype.normalize;7 }, afterEach: function () {8 /* eslint-disable no-extend-native */9 String.prototype.normalize = this.fnNormalize;10 /* eslint-enable no-extend-native */11 }12 });13 QUnit.test("apply polyfill", function(assert) {14 normalizePolyfill.apply();15 assert.ok(String.prototype.normalize);16 assert.ok(typeof String.prototype.normalize === 'function');17 });18 QUnit.test("apply polyfill and compare to prototype", function(assert) {19 normalizePolyfill.apply();20 assert.notStrictEqual(String.prototype.normalize, this.fnNormalize, "the newly set normalize function is not the same as the original");21 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('best-match');2var bm = new BestMatch();3bm.add('test', {name: 'test'});4bm.add('test2', {name: 'test2'});5bm.add('test3', {name: 'test3'});6bm.add('test4', {name: 'test4'});7bm.add('test5', {name: 'test5'});8bm.add('test6', {name: 'test6'});9bm.add('test7', {name: 'test7'});10bm.add('test8', {name: 'test8'});11bm.add('test9', {name: 'test9'});12bm.add('test10', {name: 'test10'});13bm.add('test11', {name: 'test11'});14bm.add('test12', {name: 'test12'});15bm.add('test13', {name: 'test13'});16bm.add('test14', {name: 'test14'});17bm.add('test15', {name: 'test15'});18bm.add('test16', {name: 'test16'});19bm.add('test17', {name: 'test17'});20bm.add('test18', {name: 'test18'});21bm.add('test19', {name: 'test19'});22bm.add('test20', {name: 'test20'});23bm.add('test21', {name: 'test21'});24bm.add('test22', {name: 'test22'});25bm.add('test23', {name: 'test23'});26bm.add('test24', {name: 'test24'});27bm.add('test25', {name: 'test25'});28bm.add('test26', {name: 'test26'});29bm.add('test27', {name: 'test27'});30bm.add('test28', {name: 'test28'});31bm.add('test29', {name: 'test29'});32bm.add('test30', {name: 'test30'});33bm.add('test31', {name: 'test31'});34bm.add('test32', {name: 'test32'});35bm.add('test33', {name: 'test33'});36bm.add('test34', {name: 'test34'});37bm.add('test35', {name: 'test35'});38bm.add('test36', {name: 'test36'});39bm.add('test37', {name: 'test37'});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('best-match');2var bestMatch = new BestMatch();3var arr = ['one', 'two', 'three', 'four', 'five'];4var result = bestMatch.normalize(arr);5console.log(result);6{ '0': 0,7 five: 4 }8BestMatch.prototype.normalize(arr)9BestMatch.prototype.getBestMatch(str)10var BestMatch = require('best-match');11var bestMatch = new BestMatch();12var arr = ['one', 'two', 'three', 'four', 'five'];13var result = bestMatch.getBestMatch('three');14console.log(result);15BestMatch.prototype.getBestMatch(str)16var BestMatch = require('best-match');17var bestMatch = new BestMatch();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('best-match');2var bm = new BestMatch();3bm.add('hello');4bm.add('world');5bm.add('foo');6bm.add('bar');7console.log(bm.normalize('hello world'));8console.log(bm.normalize('foo bar'));9console.log(bm.normalize('foo bar hello world'));10console.log(bm.normalize('foo bar hello world hello world'));11console.log(bm.normalize('foo bar hello world hello world hello world'));

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('./BestMatch.js');2var bm = new BestMatch();3var test = 'test';4var test2 = 'test2';5var test3 = 'test3';6var test4 = 'test4';7console.log(bm.normalize(test));8console.log(bm.normalize(test2));9console.log(bm.normalize(test3));10console.log(bm.normalize(test4));11var BestMatch = require('./BestMatch.js');12var bm = new BestMatch();13var test = 'test';14var test2 = 'test2';15var test3 = 'test3';16var test4 = 'test4';17var test5 = 'test5';18console.log(bm.normalize(test));19console.log(bm.normalize(test2));20console.log(bm.normalize(test3));21console.log(bm.normalize(test4));22console.log(bm.normalize(test5));23var BestMatch = require('./BestMatch.js');24var bm = new BestMatch();25var test = 'test';26var test2 = 'test2';27var test3 = 'test3';28var test4 = 'test4';29var test5 = 'test5';30var test6 = 'test6';31console.log(bm.normalize(test));32console.log(bm.normalize(test2));33console.log(bm.normalize(test3));34console.log(bm.normalize(test4));35console.log(bm.normalize(test5));36console.log(bm.normalize(test6));37var BestMatch = require('./BestMatch.js');38var bm = new BestMatch();39var test = 'test';40var test2 = 'test2';41var test3 = 'test3';42var test4 = 'test4';43var test5 = 'test5';44var test6 = 'test6';45var test7 = 'test7';46console.log(bm.normalize(test));47console.log(bm.normalize(test2));48console.log(bm.normalize(test3));49console.log(bm.normalize(test4));50console.log(bm.normalize(test5));51console.log(bm.normalize(test6));52console.log(bm.normalize(test7));53var BestMatch = require('./BestMatch.js');54var bm = new BestMatch();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('./BestMatch.js');2var bm = new BestMatch();3var input = ["a", "b", "c", "d"];4var output = bm.normalize(input);5console.log("Normalized array: " + output);6var BestMatch = function() {7 this.normalize = function(input) {8 var output = [];9 for (var i = 0; i < input.length; i++) {10 output[i] = input[i].toLowerCase();11 }12 return output;13 }14}15module.exports = BestMatch;

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('./BestMatch.js');2var bestMatch = new BestMatch();3var input = "This is a test string";4var dictionary = ["This", "is", "a", "test", "string", "This is a test", "string", "This is a", "test string", "This is a test string"];5var result = bestMatch.normalize(input, dictionary);6console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('./BestMatch.js');2var bm = new BestMatch();3var str = "This is a test string";4var str2 = "This is another string";5var str3 = "This is a third string";6bm.add(str);7bm.add(str2);8bm.add(str3);9console.log(bm.normalize(str));10console.log(bm.normalize(str2));11console.log(bm.normalize(str3));12var BestMatch = require('./BestMatch.js');13var bm = new BestMatch();14var str = "This is a test string";15var str2 = "This is another string";16var str3 = "This is a third string";17bm.add(str);18bm.add(str2);19bm.add(str3);20console.log(bm.find("This is a test string"));21console.log(bm.find("This is another string"));22console.log(bm.find("This is a third string"));23var BestMatch = require('./BestMatch.js');24var bm = new BestMatch();25var str = "This is a test string";26var str2 = "This is another string";27var str3 = "This is a third string";28bm.add(str);29bm.add(str2);30bm.add(str3);31console.log(bm.find("This is a test string"));32console.log(bm.find("This is another string"));33console.log(bm.find("This is a third string"));34var BestMatch = require('./BestMatch.js');35var bm = new BestMatch();36var str = "This is a test string";37var str2 = "This is another string";38var str3 = "This is a third string";39bm.add(str);40bm.add(str2);41bm.add(str3);42console.log(bm.find("This is a test string"));43console.log(bm.find("This is another string"));44console.log(bm.find("This is a third string"));

Full Screen

Using AI Code Generation

copy

Full Screen

1var br = require('./BestRoute');2var map = new br.Map();3map.addPoint(0, 0);4map.addPoint(1, 2);5map.addPoint(2, 1);6map.addPoint(3, 2);7map.addPoint(2, 3);8map.addPoint(1, 1);9map.addPoint(1, 0);10map.addPoint(0, 2);11map.addPoint(2, 0);12map.addPoint(0, 1);13map.addPoint(3, 0);14map.addPoint(0, 3);15map.addPoint(3, 1);16map.addPoint(1, 3);17map.addPoint(3, 3);18map.addPoint(2, 2);19console.log(map.normalize());20var br = require('./BestRoute');21var map = new br.Map();22map.addPoint(0, 0);23map.addPoint(1, 2);24map.addPoint(2, 1);25map.addPoint(3, 2);26map.addPoint(2, 3);27map.addPoint(1, 1);28map.addPoint(1, 0);29map.addPoint(0, 2);30map.addPoint(2, 0);31map.addPoint(0, 1);32map.addPoint(3, 0);33map.addPoint(0, 3);34map.addPoint(3, 1);35map.addPoint(1, 3);36map.addPoint(3, 3);37map.addPoint(2, 2);38console.log(map.normalize());39var br = require('./BestRoute');40var map = new br.Map();41map.addPoint(0, 0);42map.addPoint(1, 2);43map.addPoint(2, 1);44map.addPoint(3, 2);45map.addPoint(2, 3);46map.addPoint(1, 1);47map.addPoint(1, 0);48map.addPoint(0, 2);49map.addPoint(2, 0);50map.addPoint(0, 1);51map.addPoint(3, 0);52map.addPoint(0, 3);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful