Skip to content

Commit

Permalink
done migrate test/core to packages/core/test
Browse files Browse the repository at this point in the history
  • Loading branch information
giabao committed Apr 22, 2019
1 parent 73ab457 commit 9b2bc10
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 112 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ node_modules
*.test.d.ts
/test/*.d.ts
!/test/typings.d.ts
/test/qunit-ex.js*
/packages/core/test/qunit-ex.js*
/packages/core/test/qunit-ex.d.ts
/packages/*/lib/
!/packages/*/lib/types/types.d.ts
yarn-error.log
12 changes: 6 additions & 6 deletions packages/classapplier/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "lib/types",
"outDir": "lib/esm2015",
"target": "es2018"
"declarationDir": "../lib/types",
"outDir": "../lib/esm2015"
},
"references": [{"path": "../core"}]
"references": [
{"path": "../../core/src"}
]
}
8 changes: 3 additions & 5 deletions packages/core/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "lib/types",
"outDir": "lib/esm2015",
"target": "es2018"
"declarationDir": "../lib/types",
"outDir": "../lib/esm2015"
}
}
2 changes: 1 addition & 1 deletion packages/core/test/dom.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as rangy from "rangy2";
import * as rangy from "@rangy/core";

QUnit.module("Range");

Expand Down
8 changes: 4 additions & 4 deletions packages/core/test/feature.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<title>Rangy - Features Tests</title>

<!-- load rangy2 here in `head` to verify that rangy2 can init without need dom ready -->
<script src="../../dist/core/bundles/index.umd.js"></script>
<script src="../../node_modules/qunit/qunit/qunit.js"></script>
<link rel="stylesheet" href="../../node_modules/qunit/qunit/qunit.css">
<script src="../qunit-ex.js"></script>
<script src="../lib/bundles/index.umd.js"></script>
<script src="../../../node_modules/qunit/qunit/qunit.js"></script>
<link rel="stylesheet" href="../../../node_modules/qunit/qunit/qunit.css">
<script src="qunit-ex.js"></script>
</head>
<body>
<div id="qunit"></div>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/feature.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as rangy from "rangy2";
import * as rangy from "@rangy/core";
import Bowser from "bowser";

const browser = Bowser.getParser(window.navigator.userAgent);
Expand Down
8 changes: 4 additions & 4 deletions packages/core/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<meta name="referrer" content="no-referrer" />
<title>QUnit Example</title>
<!-- load rangy2 here in `head` to verify that rangy2 can init without need dom ready -->
<script src="../../dist/core/bundles/index.umd.js"></script>
<script src="../../node_modules/qunit/qunit/qunit.js"></script>
<link rel="stylesheet" href="../../node_modules/qunit/qunit/qunit.css">
<script src="../qunit-ex.js"></script>
<script src="../lib/bundles/index.umd.js"></script>
<script src="../../../node_modules/qunit/qunit/qunit.js"></script>
<link rel="stylesheet" href="../../../node_modules/qunit/qunit/qunit.css">
<script src="qunit-ex.js"></script>
</head>
<body>
<div id="qunit"></div>
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/range.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as rangy from "rangy2";
import {DomRange, RangyRange, DOMException, WrappedRange} from "rangy2";
import * as rangy from "@rangy/core";
import {DomRange, RangyRange, DOMException, WrappedRange} from "@rangy/core";

import "../qunit-ex";
import "./qunit-ex";

var hasNativeDomRange = "createRange" in document;

Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/selection.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as rangy from "rangy2";
import {RangyRangeEx, WrappedSelection} from "rangy2";
import * as rangy from "@rangy/core";
import {RangyRangeEx, WrappedSelection} from "@rangy/core";

var hasNativeGetSelection = "getSelection" in window;
var hasNativeDomRange = "createRange" in document;
Expand Down
30 changes: 4 additions & 26 deletions packages/core/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"esModuleInterop": true,
"moduleResolution": "node",
"sourceMap": true,
"stripInternal": true,
"baseUrl": ".",
"paths": {
"rangy2": ["../dist/core"],
"rangy-classapplier": ["../dist/classapplier"],
"rangy-highlighter": ["../dist/highlighter"],
"rangy-selectionsaverestore": ["../dist/selectionsaverestore"],
"rangy-serializer": ["../dist/serializer"],
"rangy-util": ["../dist/util"]
}
},
// "references": [
// { "path": "../src/core"},
// { "path": "../src/classapplier"},
// { "path": "../src/highlighter"},
// { "path": "../src/selectionsaverestore"},
// { "path": "../src/serializer"},
// { "path": "../src/util"}
// ]
// "include": ["./**/*.ts"]
"extends": "../../tsconfig.base.json",
"references": [
{ "path": "../src"}
]
}
12 changes: 5 additions & 7 deletions packages/highlighter/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "lib/types",
"outDir": "lib/esm2015",
"target": "es2018"
"declarationDir": "../lib/types",
"outDir": "../lib/esm2015"
},
"references": [
{"path": "../core"},
{"path": "../classapplier"}
{"path": "../../core/src"},
{"path": "../../classapplier/src"}
]
}
12 changes: 6 additions & 6 deletions packages/selectionsaverestore/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "lib/types",
"outDir": "lib/esm2015",
"target": "es2018"
"declarationDir": "../lib/types",
"outDir": "../lib/esm2015"
},
"references": [{"path": "../core"}]
"references": [
{"path": "../../core/src"}
]
}
12 changes: 6 additions & 6 deletions packages/serializer/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "lib/types",
"outDir": "lib/esm2015",
"target": "es2018"
"declarationDir": "../lib/types",
"outDir": "../lib/esm2015"
},
"references": [{"path": "../core"}]
"references": [
{"path": "../../core/src"}
]
}
1 change: 1 addition & 0 deletions packages/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"moduleResolution": "node",
"module": "esnext",
"target": "es2018",
"lib": [
"dom",
"es2018"
Expand Down
11 changes: 6 additions & 5 deletions packages/util/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"extends": "../tsconfig.base.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "lib/types",
"outDir": "lib/esm2015",
"declarationDir": "../lib/types",
"outDir": "../lib/esm2015",
"target": "es2018"
},
"references": [{"path": "../core"}]
"references": [
{"path": "../../core/src"}
]
}
63 changes: 34 additions & 29 deletions scripts/rollup.config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import * as glob from 'glob';
import typescript from 'rollup-plugin-typescript2'
import {packages, projectRoot} from "./util";
import {packages, packagesDir} from "./util";
import {resolve, join} from "path";
import {ModuleFormat, RollupOptions} from "rollup";

const testDir = resolve(projectRoot, 'test');

const plugins = [
const commonPlugins = [
nodeResolve(),
commonjs(),
typescript({
tsconfig: resolve(testDir, 'tsconfig.json')
}),
commonjs()
];

//all rangy modules are external dependencies to test code
Expand All @@ -28,27 +23,37 @@ const external = packages.map(n => '@rangy/' + n);
const globals = {};
external.forEach(n => Object.assign(globals, {[n]: 'rangy'}));

function config(f: string, format: ModuleFormat = 'iife'): RollupOptions {
f = join(testDir, f);
return {
input: [f],
output: {
format,
file: f.replace(/\.ts$/, format == 'iife'? '.js' : `.${format}.js`),
name: 'unnamed',
globals,
sourcemap: true
},
external,
plugins,
function configsFor(module: string) {
const cwd = resolve(packagesDir, module, 'test');
const plugins = [...commonPlugins, typescript({
tsconfig: resolve(cwd, 'tsconfig.json')
})];
function config(f: string, format: ModuleFormat = 'iife'): RollupOptions {
f = join(cwd, f);
return {
input: [f],
output: {
format,
file: f.replace(/\.ts$/, format == 'iife'? '.js' : `.${format}.js`),
name: 'unnamed',
globals,
sourcemap: true
},
external,
plugins,
}
}
}
const configs = glob
.sync('**/*.ts', {cwd})
.filter(f => !f.endsWith('.d.ts'))
.map(f => config(f));

const configs = glob
.sync('**/*.ts', {cwd: testDir})
.filter(f => !f.endsWith('.d.ts'))
.map(f => config(f));
// push amdTestExampleConfig
configs.push(config("classapplier/index.test.ts", 'amd'));
if (module == 'classapplier') {
// push amdTestExampleConfig
configs.push(config("index.test.ts", 'amd'));
}
return configs;
}

export default configs;
// export default packages.flatMap(configsFor);
export default configsFor('core');
12 changes: 6 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"composite": true
},
"references": [
{ "path": "packages/core"},
{ "path": "packages/classapplier"},
{ "path": "packages/highlighter"},
{ "path": "packages/selectionsaverestore"},
{ "path": "packages/serializer"},
{ "path": "packages/util"}
{ "path": "packages/core/src"},
{ "path": "packages/classapplier/src"},
{ "path": "packages/highlighter/src"},
{ "path": "packages/selectionsaverestore/src"},
{ "path": "packages/serializer/src"},
{ "path": "packages/util/src"}
],
"files": []
}

0 comments on commit 9b2bc10

Please sign in to comment.