mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
Housekeeping node tests, renamed to unit-tests (#4936)
Add parsers for the background css shorthand property, make ViewBase unit testable in node environment Add background parser and linear-gradient parser Use sticky regexes Simplify some types, introduce generic Parsed<T> instead of & TokenRange Apply each parser to return a { start, end, value } object Move the css selector parser to the css/parser and unify types Add the first steps toward building homegrown css parser Add somewhat standards compliant tokenizer, add baseline, rework and shady css parsers Enable all tests again, skip flaky perf test Improve css parser tokenizer by converting some char token types to simple string Implement 'parse a stylesheet' Add gonzales css-parser Add parseLib and css-tree perf Add a thin parser layer that will convert CSS3 tokens to values, for now output is compatible with rework Make root tsc green Return the requires of tns-core-modules to use relative paths for webpack to work Implement support for '@import 'url-string'; Fix function parser, function-token is no-longer neglected Make the style-scope be able to load from "css" and "css-ast" modules Add a loadAppCss event so theme can be added to snapshot separately from loaded
This commit is contained in:

committed by
Hristo Hristov

parent
2eba7c66e4
commit
f7a3a36b9c
51
unit-tests/xml/test-xml.ts
Normal file
51
unit-tests/xml/test-xml.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import {assert} from "chai";
|
||||
const xml = require("tns-core-modules/xml");
|
||||
|
||||
describe("xml parser", () => {
|
||||
let last_element = null;
|
||||
let last_attrs = null;
|
||||
let last_data = null;
|
||||
let parser = null;
|
||||
|
||||
beforeEach(() => {
|
||||
parser = new xml.XmlParser(function (event) {
|
||||
switch (event.eventType) {
|
||||
case xml.ParserEventType.StartElement:
|
||||
last_element = event.elementName;
|
||||
last_attrs = event.attributes;
|
||||
break;
|
||||
case xml.ParserEventType.Text:
|
||||
last_data = event.data;
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("handles whitespace around attribute =", () => {
|
||||
parser.parse("<TextField text = \n 'hello' />");
|
||||
|
||||
assert.equal('TextField', last_element);
|
||||
assert.equal('hello', last_attrs['text']);
|
||||
});
|
||||
|
||||
it("resolves entities", () => {
|
||||
parser.parse("<element><>"&'</element>");
|
||||
assert.equal("<>\"&'", last_data);
|
||||
});
|
||||
|
||||
it("resolves greek letter entities in attributes", () => {
|
||||
parser.parse("<element text='Ω'>blah</element>");
|
||||
assert.equal("Ω", last_attrs.text);
|
||||
});
|
||||
|
||||
it("resolves entities in element text", () => {
|
||||
parser.parse("<element>Ω</element>");
|
||||
assert.equal("Ω", last_data);
|
||||
});
|
||||
|
||||
it("resolves <> inside quotes", () => {
|
||||
parser.parse("<element name='<&>' blah=\"b<a&>\"/>");
|
||||
assert.equal("<&>", last_attrs.name);
|
||||
assert.equal("b<a&>", last_attrs.blah);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user