Best Python code snippet using robotframework
NormalizeRangeTest.js
Source:NormalizeRangeTest.js  
...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  }...normalizeColor-test.js
Source:normalizeColor-test.js  
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  });...jquery.sap.unicode.qunit.js
Source:jquery.sap.unicode.qunit.js  
...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	}...normalize-generateddata.js
Source:normalize-generateddata.js  
...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);...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
