mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
chore: housekeeping (#8129)
This commit is contained in:
107
.vscode/launch.json
vendored
107
.vscode/launch.json
vendored
@ -7,7 +7,7 @@
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Unit Tests",
|
||||
"name": "Launch mocha tests",
|
||||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
|
||||
"args": [
|
||||
"--timeout",
|
||||
@ -15,82 +15,67 @@
|
||||
"--opts",
|
||||
"unit-tests/mocha.opts"
|
||||
],
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"preLaunchTask": "tsc-unit-tests"
|
||||
},
|
||||
{
|
||||
"name": "Launch on iOS",
|
||||
"type": "nativescript",
|
||||
"request": "launch",
|
||||
"platform": "ios",
|
||||
"appRoot": "${workspaceRoot}",
|
||||
"sourceMaps": true,
|
||||
"watch": true
|
||||
},
|
||||
// {
|
||||
// "name": "Test on iOS",
|
||||
// "type": "nativescript",
|
||||
// "request": "launch",
|
||||
// "platform": "ios",
|
||||
// "appRoot": "${workspaceRoot}",
|
||||
// "sourceMaps": true,
|
||||
// "watch": false,
|
||||
// "stopOnEntry": true,
|
||||
// "launchTests": true,
|
||||
// "tnsArgs": [
|
||||
// "--justlaunch"
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
"name": "Attach on iOS",
|
||||
"type": "nativescript",
|
||||
"request": "attach",
|
||||
"platform": "ios",
|
||||
"appRoot": "${workspaceRoot}",
|
||||
"sourceMaps": true,
|
||||
"watch": false
|
||||
},
|
||||
{
|
||||
"name": "Launch on Android",
|
||||
"type": "nativescript",
|
||||
"request": "launch",
|
||||
"platform": "android",
|
||||
"appRoot": "${workspaceRoot}",
|
||||
"sourceMaps": true,
|
||||
"watch": true
|
||||
},
|
||||
{
|
||||
"name": "Debug tests on Android",
|
||||
"name": "Launch tests on Android",
|
||||
"type": "nativescript",
|
||||
"request": "launch",
|
||||
"platform": "android",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"stopOnEntry": true,
|
||||
"watch": true,
|
||||
"watch": true
|
||||
},
|
||||
// {
|
||||
// "name": "Test on Android",
|
||||
// "type": "nativescript",
|
||||
// "request": "launch",
|
||||
// "platform": "android",
|
||||
// "appRoot": "${workspaceRoot}",
|
||||
// "sourceMaps": true,
|
||||
// "watch": false,
|
||||
// "stopOnEntry": true,
|
||||
// "launchTests": true,
|
||||
// "tnsArgs": [
|
||||
// "--justlaunch"
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
"name": "Attach on Android",
|
||||
"name": "Launch tests on iOS",
|
||||
"type": "nativescript",
|
||||
"request": "launch",
|
||||
"platform": "ios",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"stopOnEntry": true,
|
||||
"watch": true
|
||||
},
|
||||
{
|
||||
"name": "Attach ui tests on Android",
|
||||
"type": "nativescript",
|
||||
"request": "attach",
|
||||
"platform": "android",
|
||||
"appRoot": "${workspaceRoot}",
|
||||
"appRoot": "${workspaceRoot}/e2e/ui-tests-app",
|
||||
"sourceMaps": true,
|
||||
"watch": false
|
||||
},
|
||||
{
|
||||
"name": "Launch ui tests on Android",
|
||||
"type": "nativescript",
|
||||
"request": "launch",
|
||||
"platform": "android",
|
||||
"appRoot": "${workspaceRoot}/e2e/ui-tests-app",
|
||||
"sourceMaps": true,
|
||||
"stopOnEntry": true,
|
||||
"watch": true
|
||||
},
|
||||
{
|
||||
"name": "Attach ui tests on iOS",
|
||||
"type": "nativescript",
|
||||
"request": "attach",
|
||||
"platform": "ios",
|
||||
"appRoot": "${workspaceRoot}/e2e/ui-tests-app",
|
||||
"sourceMaps": true,
|
||||
"watch": false
|
||||
},
|
||||
{
|
||||
"name": "Launch ui tests on iOS",
|
||||
"type": "nativescript",
|
||||
"request": "launch",
|
||||
"platform": "ios",
|
||||
"appRoot": "${workspaceRoot}/e2e/ui-tests-app",
|
||||
"sourceMaps": true,
|
||||
"stopOnEntry": true,
|
||||
"watch": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
34
.vscode/tasks.json
vendored
34
.vscode/tasks.json
vendored
@ -1,28 +1,14 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "tsc",
|
||||
"isShellCommand": true,
|
||||
"args": ["-p", "."],
|
||||
"showOutput": "always",
|
||||
"problemMatcher": "$tsc",
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "tsc-unit-tests",
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "tsc-unit-tests",
|
||||
"type": "shell",
|
||||
"problemMatcher": "$tsc",
|
||||
"command": "./node_modules/.bin/tsc",
|
||||
"args": [ "-p", "tsconfig.unit-tests.json" ]
|
||||
},
|
||||
{
|
||||
"taskName": "unit-tests",
|
||||
"command": "npm",
|
||||
"args": ["run", "unit-test"]
|
||||
},
|
||||
{
|
||||
"taskName": "unit-tests-watch",
|
||||
"command": "npm",
|
||||
"args": ["run", "unit-test-watch"]
|
||||
}
|
||||
]
|
||||
"args": [ "-p", "unit-tests/tsconfig.json" ],
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"android": {
|
||||
"v8Flags": "--expose_gc"
|
||||
"v8Flags": "--expose_gc",
|
||||
"markingMode": "none"
|
||||
},
|
||||
"main": "app.js",
|
||||
"name": "tns-template-hello-world-ts",
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"main": "app-page.js",
|
||||
"android": {
|
||||
"v8Flags": "--expose_gc"
|
||||
"v8Flags": "--expose_gc",
|
||||
"markingMode": "none"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"android": {
|
||||
"v8Flags": "--expose_gc"
|
||||
"v8Flags": "--expose_gc",
|
||||
"markingMode": "none"
|
||||
},
|
||||
"main": "app.js"
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"android": {
|
||||
"v8Flags": "--expose_gc"
|
||||
"v8Flags": "--expose_gc",
|
||||
"markingMode": "none"
|
||||
},
|
||||
"main": "app.js",
|
||||
"name": "tns-template-hello-world-ts",
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"main": "app.js",
|
||||
"android": {
|
||||
"v8Flags": "--expose_gc"
|
||||
"v8Flags": "--expose_gc",
|
||||
"markingMode": "none"
|
||||
}
|
||||
}
|
||||
|
@ -11,18 +11,15 @@ import {
|
||||
TokenObjectType,
|
||||
CSSNativeScript,
|
||||
} from "@nativescript/core/css/parser";
|
||||
import {
|
||||
parse
|
||||
} from "@nativescript/core/css";
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as shadyCss from 'shady-css-parser';
|
||||
import * as reworkCss from 'css';
|
||||
import * as shadyCss from "shady-css-parser";
|
||||
import * as reworkCss from "css";
|
||||
|
||||
const parseCss: any = require('parse-css');
|
||||
const gonzales: any = require('gonzales');
|
||||
const parseCss: any = require("parse-css");
|
||||
const gonzales: any = require("gonzales");
|
||||
const parserlib: any = require("parserlib");
|
||||
const csstree: any = require('css-tree');
|
||||
const csstree: any = require("css-tree");
|
||||
|
||||
describe("css", () => {
|
||||
describe("parser", () => {
|
||||
@ -45,7 +42,7 @@ describe("css", () => {
|
||||
describe("values", () => {
|
||||
describe("url", () => {
|
||||
test(parseURL, "url('smiley.gif') ", { start: 0, end: 19, value: "smiley.gif" });
|
||||
test(parseURL, ' url("frown.gif") ', { start: 0, end: 19, value: "frown.gif" });
|
||||
test(parseURL, " url(\"frown.gif\") ", { start: 0, end: 19, value: "frown.gif" });
|
||||
test(parseURL, " url(lucky.gif)", { start: 0, end: 16, value: "lucky.gif" });
|
||||
test(parseURL, "url(lucky.gif) #FF0000", 15, null);
|
||||
test(parseURL, "repeat url(lucky.gif) #FF0000", 6, { start: 6, end: 22, value: "lucky.gif" });
|
||||
@ -92,8 +89,8 @@ describe("css", () => {
|
||||
});
|
||||
describe("background", () => {
|
||||
test(parseBackground, " #996633 ", { start: 0, end: 12, value: { color: 0xFF996633 }});
|
||||
test(parseBackground, ' #00ff00 url("smiley.gif") repeat-y ', { start: 0, end: 37, value: { color: 0xFF00FF00, image: "smiley.gif", repeat: "repeat-y" }});
|
||||
test(parseBackground, ' url(smiley.gif) no-repeat top 50% left 100% #00ff00', { start: 0, end: 56, value: {
|
||||
test(parseBackground, " #00ff00 url(\"smiley.gif\") repeat-y ", { start: 0, end: 37, value: { color: 0xFF00FF00, image: "smiley.gif", repeat: "repeat-y" }});
|
||||
test(parseBackground, " url(smiley.gif) no-repeat top 50% left 100% #00ff00", { start: 0, end: 56, value: {
|
||||
color: 0xFF00FF00,
|
||||
image: "smiley.gif",
|
||||
repeat: "no-repeat",
|
||||
@ -103,7 +100,7 @@ describe("css", () => {
|
||||
y: { align: "top", offset: { value: 0.5, unit: "%" }}
|
||||
}
|
||||
}});
|
||||
test(parseBackground, ' url(smiley.gif) no-repeat top 50% left 100% / 100px 100px #00ff00', { start: 0, end: 70, value: {
|
||||
test(parseBackground, " url(smiley.gif) no-repeat top 50% left 100% / 100px 100px #00ff00", { start: 0, end: 70, value: {
|
||||
color: 0xFF00FF00,
|
||||
image: "smiley.gif",
|
||||
repeat: "no-repeat",
|
||||
@ -114,24 +111,24 @@ describe("css", () => {
|
||||
},
|
||||
size: { x: { value: 100, unit: "px" }, y: { value: 100, unit: "px" }}
|
||||
}});
|
||||
test(parseBackground, ' linear-gradient(to right top) ', { start: 0, end: 32, value: {
|
||||
test(parseBackground, " linear-gradient(to right top) ", { start: 0, end: 32, value: {
|
||||
image: {
|
||||
angle: Math.PI * 1/4,
|
||||
angle: Math.PI * 1 / 4,
|
||||
colors: []
|
||||
}
|
||||
}});
|
||||
test(parseBackground, ' linear-gradient(45deg, #0000FF, #00FF00) ', { start: 0, end: 43, value: {
|
||||
test(parseBackground, " linear-gradient(45deg, #0000FF, #00FF00) ", { start: 0, end: 43, value: {
|
||||
image: {
|
||||
angle: Math.PI * 1/4,
|
||||
angle: Math.PI * 1 / 4,
|
||||
colors: [
|
||||
{ argb: 0xFF0000FF },
|
||||
{ argb: 0xFF00FF00 }
|
||||
]
|
||||
}
|
||||
}});
|
||||
test(parseBackground, 'linear-gradient(0deg, blue, green 40%, red)', { start: 0, end: 43, value: {
|
||||
test(parseBackground, "linear-gradient(0deg, blue, green 40%, red)", { start: 0, end: 43, value: {
|
||||
image: {
|
||||
angle: Math.PI * 0/4,
|
||||
angle: Math.PI * 0 / 4,
|
||||
colors: [
|
||||
{ argb: 0xFF0000FF },
|
||||
{ argb: 0xFF008000, offset: { value: 0.4, unit: "%" }},
|
||||
@ -229,15 +226,23 @@ describe("css", () => {
|
||||
|
||||
let original = themeCoreLightIos.replace(/\/\*([^\/]|\/[^\*])*\*\//g, "").replace(/\n/g, " ");
|
||||
let roundtrip = stylesheet.map(m => {
|
||||
if (!m) return "";
|
||||
if (typeof m === "string") return m;
|
||||
if (!m) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (typeof m === "string") {
|
||||
return m;
|
||||
}
|
||||
|
||||
return m.text;
|
||||
}).join("");
|
||||
|
||||
let lastIndex = Math.min(original.length, roundtrip.length);
|
||||
for(var i = 0; i < lastIndex; i++)
|
||||
if (original[i] != roundtrip[i])
|
||||
for (var i = 0; i < lastIndex; i++) {
|
||||
if (original[i] !== roundtrip[i]) {
|
||||
assert.equal(roundtrip.substr(i, 50), original.substr(i, 50), "Round-tripped CSS string differ at index: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(roundtrip.length, original.length, "Expected round-tripped string lengths to match.");
|
||||
});
|
||||
@ -319,7 +324,7 @@ describe("css", () => {
|
||||
const parser = new CSS3Parser(".btn-primary{border-color:rgba(255,0,0,0)}");
|
||||
const stylesheet = parser.parseAStylesheet();
|
||||
|
||||
assert.deepEqual(stylesheet, {rules:[
|
||||
assert.deepEqual(stylesheet, {rules: [
|
||||
{
|
||||
type: "qualified-rule",
|
||||
prelude: [{ type: 2, text: "." }, { type: 6, text: "btn-primary" }],
|
||||
@ -370,6 +375,7 @@ describe("css", () => {
|
||||
const [startSec, startMSec] = process.hrtime();
|
||||
action();
|
||||
const [endSec, endMSec] = process.hrtime();
|
||||
|
||||
return (endSec - startSec) * 1000 + (endMSec - startMSec) / 1000000;
|
||||
}
|
||||
const charCodeByCharCodeDuration = trapDuration(() => {
|
||||
@ -390,7 +396,7 @@ describe("css", () => {
|
||||
let char;
|
||||
let c = 0;
|
||||
for (let i = 0; i < themeCoreLightIos.length; i++) {
|
||||
const char = themeCoreLightIos[i];
|
||||
char = themeCoreLightIos[i];
|
||||
if ((char >= "a" && char <= "z") || (char >= "A" && char <= "Z") || char === "_") {
|
||||
c++;
|
||||
}
|
||||
@ -402,7 +408,7 @@ describe("css", () => {
|
||||
let char;
|
||||
let c = 0;
|
||||
for (let i = 0; i < themeCoreLightIos.length; i++) {
|
||||
const char = themeCoreLightIos[i];
|
||||
char = themeCoreLightIos[i];
|
||||
if (compareCharRegEx.test(char)) {
|
||||
c++;
|
||||
}
|
||||
|
@ -22,12 +22,14 @@ describe("ui", () => {
|
||||
let rulesAst = parse.stylesheet.rules.filter(n => n.type === "rule");
|
||||
let rules = selector.fromAstNodes(rulesAst);
|
||||
let map = new selector.SelectorsMap(rules);
|
||||
|
||||
return { rules, map };
|
||||
}
|
||||
|
||||
function createOne(css: string, source: string = "css-selectors.ts@test"): selector.RuleSet {
|
||||
let {rules} = create(css, source);
|
||||
assert.equal(rules.length, 1);
|
||||
|
||||
return rules[0];
|
||||
}
|
||||
|
||||
@ -76,8 +78,8 @@ describe("ui", () => {
|
||||
".class": (view) => view.cssClasses.has("class"),
|
||||
":pseudo": (view) => view.cssPseudoClasses.has("pseudo"),
|
||||
"[src1]": (view) => "src1" in view,
|
||||
"[src2='src-value']": (view) => view['src2'] === 'src-value'
|
||||
}
|
||||
"[src2='src-value']": (view) => view["src2"] === "src-value"
|
||||
};
|
||||
|
||||
let positivelyMatchingView = {
|
||||
cssType: "type",
|
||||
@ -86,7 +88,7 @@ describe("ui", () => {
|
||||
cssPseudoClasses: new Set(["pseudo"]),
|
||||
"src1": "src",
|
||||
"src2": "src-value"
|
||||
}
|
||||
};
|
||||
|
||||
let negativelyMatchingView = {
|
||||
cssType: "nottype",
|
||||
@ -95,7 +97,7 @@ describe("ui", () => {
|
||||
cssPseudoClasses: new Set(["notpseudo"]),
|
||||
// Has no "src1"
|
||||
"src2": "not-src-value"
|
||||
}
|
||||
};
|
||||
|
||||
it("simple selectors match", () => {
|
||||
for (let sel in positiveMatches) {
|
||||
@ -191,7 +193,8 @@ describe("ui", () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
assert.isTrue(sel.match(child));
|
||||
});
|
||||
|
||||
@ -215,7 +218,7 @@ describe("ui", () => {
|
||||
toString
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let match = map.query(button);
|
||||
assert.equal(match.selectors.length, 1, "Expected match to have one selector.");
|
||||
|
Reference in New Issue
Block a user