Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 42bf1a0

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
test: test Arduino state update for extensions
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 5abdc18 commit 42bf1a0

File tree

7 files changed

+716
-11
lines changed

7 files changed

+716
-11
lines changed

‎arduino-ide-extension/src/browser/contributions/update-arduino-state.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import { BoardsServiceProvider } from '../boards/boards-service-provider';
2121
import { CurrentSketch } from '../sketches-service-client-impl';
2222
import { SketchContribution } from './contribution';
2323

24-
interface UpdateStateParams<T extends ArduinoState> {
24+
/**
25+
* (non-API) exported for tests
26+
*/
27+
export interface UpdateStateParams<T extends ArduinoState = ArduinoState> {
2528
readonly key: keyof T;
2629
readonly value: T[keyof T];
2730
}

‎arduino-ide-extension/src/test/browser/board-service-provider.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
uno,
4040
unoSerialPort,
4141
} from '../common/fixtures';
42+
import { bindBrowser } from './browser-test-bindings';
4243

4344
disableJSDOM();
4445

@@ -390,7 +391,7 @@ describe('board-service-provider', () => {
390391
const container = new Container({ defaultScope: 'Singleton' });
391392
container.load(
392393
new ContainerModule((bind, unbind, isBound, rebind) => {
393-
bindCommon(bind);
394+
bindBrowser(bind,unbind,isBound,rebind);
394395
bind(MessageService).toConstantValue(<MessageService>{});
395396
bind(BoardsService).toConstantValue(<BoardsService>{
396397
getDetectedPorts() {
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1+
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
12
import { Container, ContainerModule } from '@theia/core/shared/inversify';
2-
import { bindCommon } from '../common/common-test-bindings';
3+
import {
4+
Bind,
5+
ConsoleLogger,
6+
bindCommon,
7+
} from '../common/common-test-bindings';
38

4-
export function createBaseContainer(): Container {
9+
export function createBaseContainer(bind: Bind=bindBrowser): Container {
510
const container = new Container({ defaultScope: 'Singleton' });
6-
container.load(new ContainerModule((bind)=>bindCommon(bind)));
11+
container.load(new ContainerModule(bind));
712
return container;
813
}
14+
15+
export const bindBrowser: Bind = function (
16+
...args: Parameters<Bind>
17+
): ReturnType<Bind> {
18+
bindCommon(...args);
19+
const [bind, , , rebind] = args;
20+
// IDE2's test console logger does not support `Loggable` arg.
21+
// Rebind logger to suppress `[Function (anonymous)]` messages in tests when the storage service is initialized without `window.localStorage`.
22+
// https://github.com/eclipse-theia/theia/blob/04c8cf07843ea67402131132e033cdd54900c010/packages/core/src/browser/storage-service.ts#L60
23+
bind(MockLogger).toSelf().inSingletonScope();
24+
rebind(ConsoleLogger).toService(MockLogger);
25+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /