Skip to content

Commit b074e61

Browse files
committed
[lumino] mock DragEvent in test setup
'@lumino/dragdrop' consumes DragEvent already at loading time. Therefore the DragEvent mock must already be available before executing the tests. Adds a new private '@theia/test-setup' dev package which is consumed in the mocha config to mock 'DragEvent' before loading and compiling tests. Contributed on behalf of STMicroelectronics
1 parent 2e8a052 commit b074e61

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

configs/mocharc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require:
22
- 'ignore-styles'
33
- 'reflect-metadata/Reflect'
4+
- '@theia/test-setup'
45
reporter: 'spec'
56
watch-files:
67
- '**/*.js'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div align='center'>
2+
3+
<br />
4+
5+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6+
7+
<h2>ECLIPSE THEIA - TEST SETUP</h2>
8+
9+
<hr />
10+
11+
</div>
12+
13+
## Description
14+
15+
The `@theia/test-setup` contributes a setup script for mocha executed tests in Theia.
16+
This setup script is executed before any test file is loaded or compiled.
17+
This is for example useful for globals which must exist before dependencies are loaded.
18+
19+
## Additional Information
20+
21+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
22+
- [Theia - Website](https://theia-ide.org/)
23+
24+
## License
25+
26+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
27+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
28+
29+
## Trademark
30+
31+
"Theia" is a trademark of the Eclipse Foundation
32+
https://www.eclipse.org/theia
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"private": true,
3+
"name": "@theia/test-setup",
4+
"version": "1.56.0",
5+
"description": "Custom setup for mocha tests",
6+
"main": "test-setup.js"
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// *****************************************************************************
2+
// Copyright (C) 2024 STMicroelectronics and others.
3+
//
4+
// This program and the accompanying materials are made available under the
5+
// terms of the Eclipse Public License v. 2.0 which is available at
6+
// http://www.eclipse.org/legal/epl-2.0.
7+
//
8+
// This Source Code may also be made available under the following Secondary
9+
// Licenses when the conditions for such availability set forth in the Eclipse
10+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
// with the GNU Classpath Exception which is available at
12+
// https://www.gnu.org/software/classpath/license.html.
13+
//
14+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15+
// *****************************************************************************
16+
17+
// Mock DragEvent as '@lumino/dragdrop' already requires it at require time
18+
global.DragEvent = class DragEvent { };

0 commit comments

Comments
 (0)