1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const inversify_1 = require("inversify");
|
19 | const window_service_1 = require("./window/window-service");
|
20 | const mock_window_service_1 = require("./window/test/mock-window-service");
|
21 | const storage_service_1 = require("./storage-service");
|
22 | const chai_1 = require("chai");
|
23 | const logger_1 = require("../common/logger");
|
24 | const mock_logger_1 = require("../common/test/mock-logger");
|
25 | const sinon = require("sinon");
|
26 | const common_1 = require("../common/");
|
27 | let storageService;
|
28 | before(() => {
|
29 | const testContainer = new inversify_1.Container();
|
30 | testContainer.bind(logger_1.ILogger).toDynamicValue(ctx => {
|
31 | const logger = new mock_logger_1.MockLogger();
|
32 | |
33 |
|
34 |
|
35 |
|
36 | sinon.stub(logger, 'warn').callsFake(async () => { });
|
37 | return logger;
|
38 | });
|
39 | testContainer.bind(storage_service_1.StorageService).to(storage_service_1.LocalStorageService).inSingletonScope();
|
40 | testContainer.bind(window_service_1.WindowService).to(mock_window_service_1.MockWindowService).inSingletonScope();
|
41 | testContainer.bind(storage_service_1.LocalStorageService).toSelf().inSingletonScope();
|
42 | testContainer.bind(common_1.MessageClient).toSelf().inSingletonScope();
|
43 | testContainer.bind(common_1.MessageService).toSelf().inSingletonScope();
|
44 | storageService = testContainer.get(storage_service_1.StorageService);
|
45 | });
|
46 | describe('storage-service', () => {
|
47 | it('stores data', async () => {
|
48 | storageService.setData('foo', {
|
49 | test: 'foo'
|
50 | });
|
51 | (0, chai_1.expect)(await storageService.getData('bar', 'bar')).equals('bar');
|
52 | (0, chai_1.expect)((await storageService.getData('foo', {
|
53 | test: 'bar'
|
54 | })).test).equals('foo');
|
55 | });
|
56 | it('removes data', async () => {
|
57 | storageService.setData('foo', {
|
58 | test: 'foo'
|
59 | });
|
60 | (0, chai_1.expect)((await storageService.getData('foo', {
|
61 | test: 'bar'
|
62 | })).test).equals('foo');
|
63 | storageService.setData('foo', undefined);
|
64 | (0, chai_1.expect)((await storageService.getData('foo', {
|
65 | test: 'bar'
|
66 | })).test).equals('bar');
|
67 | });
|
68 | });
|
69 |
|
\ | No newline at end of file |