@microsoft/mgt-element
Advanced tools
Comparing version 3.1.3-preview.4b85be1 to 3.1.3-preview.59cccb0
@@ -11,3 +11,3 @@ /** | ||
import { ComponentMiddlewareOptions } from './utils/ComponentMiddlewareOptions'; | ||
import { chainMiddleware } from './utils/GraphHelpers'; | ||
import { chainMiddleware } from './utils/chainMiddleware'; | ||
import { SdkVersionMiddleware } from './utils/SdkVersionMiddleware'; | ||
@@ -14,0 +14,0 @@ import { PACKAGE_VERSION } from './utils/version'; |
@@ -18,7 +18,12 @@ /** | ||
export * from './providers/SimpleProvider'; | ||
export * from './utils/CacheItem'; | ||
export * from './utils/CacheSchema'; | ||
export * from './utils/CacheService'; | ||
export * from './utils/CacheStore'; | ||
export * from './utils/dbListKey'; | ||
export * from './utils/EventDispatcher'; | ||
export * from './utils/equals'; | ||
export * from './utils/GraphHelpers'; | ||
export * from './utils/chainMiddleware'; | ||
export * from './utils/prepScopes'; | ||
export * from './utils/validateBaseURL'; | ||
export * from './utils/TeamsHelper'; | ||
@@ -31,2 +36,3 @@ export * from './utils/TemplateContext'; | ||
export * from './utils/CustomElement'; | ||
export * from './utils/registerComponent'; | ||
export { PACKAGE_VERSION } from './utils/version'; | ||
@@ -33,0 +39,0 @@ export * from './CollectionResponse'; |
@@ -18,7 +18,12 @@ /** | ||
export * from './providers/SimpleProvider'; | ||
export * from './utils/CacheItem'; | ||
export * from './utils/CacheSchema'; | ||
export * from './utils/CacheService'; | ||
export * from './utils/CacheStore'; | ||
export * from './utils/dbListKey'; | ||
export * from './utils/EventDispatcher'; | ||
export * from './utils/equals'; | ||
export * from './utils/GraphHelpers'; | ||
export * from './utils/chainMiddleware'; | ||
export * from './utils/prepScopes'; | ||
export * from './utils/validateBaseURL'; | ||
export * from './utils/TeamsHelper'; | ||
@@ -31,2 +36,3 @@ export * from './utils/TemplateContext'; | ||
export * from './utils/CustomElement'; | ||
export * from './utils/registerComponent'; | ||
export { PACKAGE_VERSION } from './utils/version'; | ||
@@ -33,0 +39,0 @@ export * from './CollectionResponse'; |
@@ -18,3 +18,3 @@ /** | ||
import { Graph } from '../Graph'; | ||
import { chainMiddleware } from '../utils/GraphHelpers'; | ||
import { chainMiddleware } from '../utils/chainMiddleware'; | ||
import { MockMiddleware } from './MockMiddleware'; | ||
@@ -21,0 +21,0 @@ /** |
@@ -11,3 +11,3 @@ /** | ||
/** | ||
* Provider Type to be extended for implmenting new providers | ||
* Provider Type to be extended for implementing new providers | ||
* | ||
@@ -14,0 +14,0 @@ * @export |
@@ -7,7 +7,7 @@ /** | ||
*/ | ||
import { validateBaseURL } from '../utils/GraphHelpers'; | ||
import { validateBaseURL } from '../utils/validateBaseURL'; | ||
import { MICROSOFT_GRAPH_DEFAULT_ENDPOINT } from '../IGraph'; | ||
import { EventDispatcher } from '../utils/EventDispatcher'; | ||
/** | ||
* Provider Type to be extended for implmenting new providers | ||
* Provider Type to be extended for implementing new providers | ||
* | ||
@@ -14,0 +14,0 @@ * @export |
@@ -18,4 +18,4 @@ /** | ||
import { BatchRequestContent } from '@microsoft/microsoft-graph-client'; | ||
import { delay } from '../utils'; | ||
import { prepScopes } from './GraphHelpers'; | ||
import { delay } from './delay'; | ||
import { prepScopes } from './prepScopes'; | ||
import { BatchRequest } from './BatchRequest'; | ||
@@ -22,0 +22,0 @@ /** |
@@ -8,10 +8,5 @@ /** | ||
import { CacheStore } from './CacheStore'; | ||
import { CacheSchema } from './CacheSchema'; | ||
import { CacheItem } from './CacheItem'; | ||
/** | ||
* Localstorage key for storing names of cache databases | ||
* | ||
* @type {string} | ||
* | ||
*/ | ||
export declare const dbListKey = "mgt-db-list"; | ||
/** | ||
* Holds the cache options for cache store | ||
@@ -164,46 +159,2 @@ * | ||
} | ||
/** | ||
* Represents organization for a cache | ||
* | ||
* @export | ||
* @interface CacheSchema | ||
*/ | ||
export interface CacheSchema { | ||
/** | ||
* version number of cache, useful for upgrading | ||
* | ||
* @type {number} | ||
* @memberof CacheSchema | ||
*/ | ||
version: number; | ||
/** | ||
* name of the cache | ||
* | ||
* @type {string} | ||
* @memberof CacheSchema | ||
*/ | ||
name: string; | ||
/** | ||
* list of stores in the cache | ||
* | ||
* @type {{ [name: string]: CacheSchemaStore }} | ||
* @memberof CacheSchema | ||
*/ | ||
stores: Record<string, string>; | ||
} | ||
/** | ||
* item that is stored in cache | ||
* | ||
* @export | ||
* @interface CacheItem | ||
*/ | ||
export interface CacheItem { | ||
/** | ||
* date and time that item was retrieved from api/stored in cache | ||
* | ||
* @type {number} | ||
* @memberof CacheItem | ||
*/ | ||
timeCached?: number; | ||
} | ||
//# sourceMappingURL=CacheService.d.ts.map |
@@ -19,10 +19,4 @@ /** | ||
import { CacheStore } from './CacheStore'; | ||
import { dbListKey } from './dbListKey'; | ||
/** | ||
* Localstorage key for storing names of cache databases | ||
* | ||
* @type {string} | ||
* | ||
*/ | ||
export const dbListKey = 'mgt-db-list'; | ||
/** | ||
* class in charge of managing all the caches and their stores | ||
@@ -29,0 +23,0 @@ * |
@@ -7,3 +7,4 @@ /** | ||
*/ | ||
import { CacheItem, CacheSchema } from './CacheService'; | ||
import { CacheItem } from './CacheItem'; | ||
import { CacheSchema } from './CacheSchema'; | ||
/** | ||
@@ -10,0 +11,0 @@ * Represents a store in the cache |
@@ -18,3 +18,3 @@ /** | ||
import { Providers } from '../providers/Providers'; | ||
import { dbListKey } from './CacheService'; | ||
import { dbListKey } from './dbListKey'; | ||
/** | ||
@@ -21,0 +21,0 @@ * Represents a store in the cache |
@@ -1,8 +0,2 @@ | ||
/** | ||
* ------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. | ||
* See License in the project root for license information. | ||
* ------------------------------------------------------------------------------------------- | ||
*/ | ||
export {}; | ||
//# sourceMappingURL=equals.tests.d.ts.map |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
/** | ||
@@ -7,3 +8,3 @@ * ------------------------------------------------------------------------------------------- | ||
*/ | ||
import { it } from '@jest/globals'; | ||
import { expect } from '@open-wc/testing'; | ||
import { equals } from './equals'; | ||
@@ -17,34 +18,40 @@ describe('objectEquals', () => { | ||
const simpleDate = new Date(0); | ||
it.each([ | ||
[{}, {}], | ||
[ | ||
{ a: 1, b: true, c: 'foo' }, | ||
{ c: 'foo', b: true, a: 1 } | ||
], | ||
[{ a: [1, 2, 3] }, { a: [1, 2, 3] }], | ||
[{ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [3]]] }], | ||
[circularObject, circularObject], | ||
[circularObject, { a: circularObject }], | ||
[circularArray, circularArray], | ||
[ | ||
{ a: circularObject, b: circularArray }, | ||
{ a: circularObject, b: circularArray } | ||
], | ||
[{ a: simpleDate }, { a: simpleDate }] | ||
])('should return true between %p and %p', (o1, o2) => { | ||
expect(equals(o1, o2)).toBe(true); | ||
it('should return true', () => { | ||
const testValues = [ | ||
[{}, {}], | ||
[ | ||
{ a: 1, b: true, c: 'foo' }, | ||
{ c: 'foo', b: true, a: 1 } | ||
], | ||
[{ a: [1, 2, 3] }, { a: [1, 2, 3] }], | ||
[{ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [3]]] }], | ||
[circularObject, circularObject], | ||
[circularObject, { a: circularObject }], | ||
[circularArray, circularArray], | ||
[ | ||
{ a: circularObject, b: circularArray }, | ||
{ a: circularObject, b: circularArray } | ||
], | ||
[{ a: simpleDate }, { a: simpleDate }] | ||
]; | ||
for (const [o1, o2] of testValues) { | ||
expect(equals(o1, o2)).to.be.true; | ||
} | ||
}); | ||
it.each([ | ||
[{ a: {} }, { a: [] }], | ||
[{ a: [1, 2, 3] }, { a: [3, 2, 1] }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [4]]] }], | ||
[{ a: { b: [{ c: 1 }, { d: [2, 3] }] } }, { a: { b: [{ c: 1 }, { d: [3, 2] }] } }], | ||
[{ a: new Date() }, { a: new Date() }], | ||
[circularObject, circularArray], | ||
[circularObject, { b: circularObject }] | ||
])('should return false between %p and %p', (o1, o2) => { | ||
expect(equals(o1, o2)).toBe(false); | ||
it('should return false ', () => { | ||
const testValues = [ | ||
[{ a: {} }, { a: [] }], | ||
[{ a: [1, 2, 3] }, { a: [3, 2, 1] }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [4]]] }], | ||
[{ a: { b: [{ c: 1 }, { d: [2, 3] }] } }, { a: { b: [{ c: 1 }, { d: [3, 2] }] } }], | ||
[{ a: new Date() }, { a: new Date() }], | ||
[circularObject, circularArray], | ||
[circularObject, { b: circularObject }] | ||
]; | ||
for (const [o1, o2] of testValues) { | ||
expect(equals(o1, o2)).to.be.false; | ||
} | ||
}); | ||
}); | ||
//# sourceMappingURL=equals.tests.js.map |
@@ -7,19 +7,22 @@ /** | ||
*/ | ||
import { it } from '@jest/globals'; | ||
import { assert } from 'console'; | ||
import { EventDispatcher } from './EventDispatcher'; | ||
import { assert, restore, fake } from 'sinon'; | ||
describe('EventDispatcher tests', () => { | ||
afterEach(() => { | ||
// Restore the default sandbox here | ||
restore(); | ||
}); | ||
it('should add and remove event handlers', () => { | ||
const dispatcher = new EventDispatcher(); | ||
const handler1 = jest.fn(); | ||
const handler2 = jest.fn(); | ||
const handler1 = fake(); | ||
const handler2 = fake(); | ||
dispatcher.add(handler1); | ||
dispatcher.add(handler2); | ||
dispatcher.fire('event'); | ||
expect(handler1).toHaveBeenCalledTimes(1); | ||
expect(handler2).toHaveBeenCalledTimes(1); | ||
assert.calledOnce(handler1); | ||
assert.calledOnce(handler2); | ||
dispatcher.remove(handler1); | ||
dispatcher.fire('event'); | ||
expect(handler1).toHaveBeenCalledTimes(1); | ||
expect(handler2).toHaveBeenCalledTimes(2); | ||
assert.calledOnce(handler1); | ||
assert.callCount(handler2, 2); | ||
}); | ||
@@ -29,11 +32,11 @@ it('should not throw when remove is called with an unregistered handler', () => { | ||
const dispatcher = new EventDispatcher(); | ||
const handler1 = jest.fn(); | ||
const handler1 = fake(); | ||
dispatcher.remove(handler1); | ||
} | ||
catch (e) { | ||
assert(false, 'should not throw'); | ||
assert.fail('should not throw'); | ||
} | ||
assert(true, 'did not throw'); | ||
assert.pass('did not throw'); | ||
}); | ||
}); | ||
//# sourceMappingURL=EventDispatcher.tests.js.map |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
/** | ||
@@ -7,31 +8,44 @@ * ------------------------------------------------------------------------------------------- | ||
*/ | ||
import { it } from '@jest/globals'; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { expect } from '@open-wc/testing'; | ||
import { fake } from 'sinon'; | ||
import { AuthenticationHandlerOptions } from '@microsoft/microsoft-graph-client'; | ||
import { MockProvider } from '../mock/MockProvider'; | ||
import { Providers } from '../providers/Providers'; | ||
import { chainMiddleware, prepScopes, validateBaseURL } from './GraphHelpers'; | ||
import { chainMiddleware } from './chainMiddleware'; | ||
import { prepScopes } from './prepScopes'; | ||
import { validateBaseURL } from './validateBaseURL'; | ||
describe('GraphHelpers - prepScopes', () => { | ||
it('should return an empty array when incremental consent is disabled', () => { | ||
it('should return an empty array when incremental consent is disabled', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const scopes = ['scope1', 'scope2']; | ||
Providers.globalProvider = new MockProvider(true); | ||
Providers.globalProvider.isIncrementalConsentDisabled = true; | ||
expect(prepScopes(...scopes)).toEqual([]); | ||
}); | ||
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled', () => { | ||
// eql for loose equality | ||
yield expect(prepScopes(...scopes)).to.eql([]); | ||
})); | ||
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const scopes = ['scope1', 'scope2']; | ||
Providers.globalProvider = new MockProvider(true); | ||
Providers.globalProvider.isIncrementalConsentDisabled = false; | ||
expect(prepScopes(...scopes)).toEqual([new AuthenticationHandlerOptions(undefined, { scopes })]); | ||
}); | ||
yield expect(prepScopes(...scopes)).to.eql([new AuthenticationHandlerOptions(undefined, { scopes })]); | ||
})); | ||
}); | ||
describe('GraphHelpers - chainMiddleware', () => { | ||
it('should return the first middleware when only one is passed', () => { | ||
const middleware = [{ execute: jest.fn(), setNext: jest.fn() }]; | ||
it('should return the first middleware when only one is passed', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const middleware = [{ execute: fake(), setNext: fake() }]; | ||
const result = chainMiddleware(...middleware); | ||
expect(result).toEqual(middleware[0]); | ||
}); | ||
yield expect(result).to.equal(middleware[0]); | ||
})); | ||
it('should return undefined when the middleware array is empty', () => { | ||
const middleware = []; | ||
const result = chainMiddleware(...middleware); | ||
expect(result).toBeUndefined(); | ||
expect(result).to.be.undefined; | ||
}); | ||
@@ -42,3 +56,3 @@ it('should now throw when the middleware array is undefined', () => { | ||
const result = chainMiddleware(undefined); | ||
expect(result).toBeUndefined(); | ||
expect(result).to.be.undefined; | ||
} | ||
@@ -48,22 +62,31 @@ catch (e) { | ||
} | ||
expect(error).toBeUndefined(); | ||
expect(error).to.be.undefined; | ||
}); | ||
}); | ||
describe('GraphHelpers - validateBaseUrl', () => { | ||
it.each([ | ||
'https://graph.microsoft.com', | ||
'https://graph.microsoft.us', | ||
'https://dod-graph.microsoft.us', | ||
'https://graph.microsoft.de', | ||
'https://microsoftgraph.chinacloudapi.cn' | ||
])('should return %p as a valid base url', (graphUrl) => { | ||
expect(validateBaseURL(graphUrl)).toBe(graphUrl); | ||
it('should return as a valid Url', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const validUrls = [ | ||
'https://graph.microsoft.com', | ||
'https://graph.microsoft.us', | ||
'https://dod-graph.microsoft.us', | ||
'https://graph.microsoft.de', | ||
'https://microsoftgraph.chinacloudapi.cn' | ||
]; | ||
for (const url of validUrls) { | ||
yield expect(validateBaseURL(url)).to.equal(url); | ||
} | ||
})); | ||
it('should return undefeined for invalid Url', () => { | ||
const validUrls = ['https://graph.microsoft.net', 'https://random.us', 'https://nope.cn']; | ||
for (const url of validUrls) { | ||
expect(validateBaseURL(url)).to.be.undefined; | ||
} | ||
}); | ||
it.each(['https://graph.microsoft.net', 'https://random.us', 'https://nope.cn'])('should return undefined for %p as an invalid base url', (graphUrl) => { | ||
expect(validateBaseURL(graphUrl)).toBeUndefined(); | ||
it('should return undefined for when supplied a %p which is not a well formed url', () => { | ||
const testValues = ['not a url', 'graph.microsoft.com']; | ||
for (const test of testValues) { | ||
expect(validateBaseURL(test)).to.be.undefined; | ||
} | ||
}); | ||
it.each(['not a url', 'graph.microsoft.com'])('should return undefined for when supplied a %p which is not a well formed url', (input) => { | ||
expect(validateBaseURL(input)).toBeUndefined(); | ||
}); | ||
}); | ||
//# sourceMappingURL=GraphHelpers.tests.js.map |
@@ -18,3 +18,3 @@ /** | ||
import { ComponentMiddlewareOptions } from './ComponentMiddlewareOptions'; | ||
import { validateBaseURL } from './GraphHelpers'; | ||
import { validateBaseURL } from './validateBaseURL'; | ||
/** | ||
@@ -21,0 +21,0 @@ * Implements Middleware for the Graph sdk to inject |
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
export declare const PACKAGE_VERSION = "3.1.3-preview.4b85be1"; | ||
export declare const PACKAGE_VERSION = "3.1.3-preview.59cccb0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -9,3 +9,3 @@ /** | ||
// ANY CHANGES WILL BE LOST DURING BUILD | ||
export const PACKAGE_VERSION = '3.1.3-preview.4b85be1'; | ||
export const PACKAGE_VERSION = '3.1.3-preview.59cccb0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@microsoft/mgt-element", | ||
"version": "3.1.3-preview.4b85be1", | ||
"version": "3.1.3-preview.59cccb0", | ||
"description": "Microsoft Graph Toolkit base classes", | ||
@@ -33,6 +33,7 @@ "homepage": "https://github.com/microsoftgraph/microsoft-graph-toolkit", | ||
}, | ||
"sideEffects": false, | ||
"dependencies": { | ||
"@microsoft/microsoft-graph-client": "3.0.2", | ||
"idb": "6.0.0", | ||
"lit": "^2.3.1" | ||
"lit": "^3.0.0" | ||
}, | ||
@@ -39,0 +40,0 @@ "publishConfig": { |
@@ -27,3 +27,4 @@ # Microsoft Graph Toolkit Base package | ||
import {Providers} from '@microsoft/mgt-element'; | ||
import {Msal2Provider} from '@microsoft/mgt-msal2-provider'; | ||
// importing via the export path will exclude the custom element for <mgt-msal2-proivder> from the final bundle | ||
import {Msal2Provider} from '@microsoft/mgt-msal2-provider/dist/es6/exports'; | ||
@@ -30,0 +31,0 @@ // initialize the auth provider globally |
@@ -24,3 +24,3 @@ /** | ||
import { ComponentMiddlewareOptions } from './utils/ComponentMiddlewareOptions'; | ||
import { chainMiddleware } from './utils/GraphHelpers'; | ||
import { chainMiddleware } from './utils/chainMiddleware'; | ||
import { SdkVersionMiddleware } from './utils/SdkVersionMiddleware'; | ||
@@ -27,0 +27,0 @@ import { PACKAGE_VERSION } from './utils/version'; |
@@ -22,7 +22,12 @@ /** | ||
export * from './utils/CacheItem'; | ||
export * from './utils/CacheSchema'; | ||
export * from './utils/CacheService'; | ||
export * from './utils/CacheStore'; | ||
export * from './utils/dbListKey'; | ||
export * from './utils/EventDispatcher'; | ||
export * from './utils/equals'; | ||
export * from './utils/GraphHelpers'; | ||
export * from './utils/chainMiddleware'; | ||
export * from './utils/prepScopes'; | ||
export * from './utils/validateBaseURL'; | ||
export * from './utils/TeamsHelper'; | ||
@@ -35,2 +40,4 @@ export * from './utils/TemplateContext'; | ||
export * from './utils/CustomElement'; | ||
export * from './utils/registerComponent'; | ||
export { PACKAGE_VERSION } from './utils/version'; | ||
@@ -37,0 +44,0 @@ |
@@ -19,3 +19,3 @@ /** | ||
import { Graph } from '../Graph'; | ||
import { chainMiddleware } from '../utils/GraphHelpers'; | ||
import { chainMiddleware } from '../utils/chainMiddleware'; | ||
@@ -22,0 +22,0 @@ import { MockProvider } from './MockProvider'; |
@@ -9,3 +9,3 @@ /** | ||
import { AuthenticationProvider, AuthenticationProviderOptions } from '@microsoft/microsoft-graph-client'; | ||
import { validateBaseURL } from '../utils/GraphHelpers'; | ||
import { validateBaseURL } from '../utils/validateBaseURL'; | ||
import { GraphEndpoint, IGraph, MICROSOFT_GRAPH_DEFAULT_ENDPOINT } from '../IGraph'; | ||
@@ -15,3 +15,3 @@ import { EventDispatcher, EventHandler } from '../utils/EventDispatcher'; | ||
/** | ||
* Provider Type to be extended for implmenting new providers | ||
* Provider Type to be extended for implementing new providers | ||
* | ||
@@ -18,0 +18,0 @@ * @export |
@@ -10,4 +10,4 @@ /** | ||
import { BatchRequestContent, MiddlewareOptions } from '@microsoft/microsoft-graph-client'; | ||
import { delay } from '../utils'; | ||
import { prepScopes } from './GraphHelpers'; | ||
import { delay } from './delay'; | ||
import { prepScopes } from './prepScopes'; | ||
import { IGraph } from '../IGraph'; | ||
@@ -14,0 +14,0 @@ import { BatchRequest } from './BatchRequest'; |
@@ -11,12 +11,7 @@ /** | ||
import { CacheStore } from './CacheStore'; | ||
import { CacheSchema } from './CacheSchema'; | ||
import { CacheItem } from './CacheItem'; | ||
import { dbListKey } from './dbListKey'; | ||
/** | ||
* Localstorage key for storing names of cache databases | ||
* | ||
* @type {string} | ||
* | ||
*/ | ||
export const dbListKey = 'mgt-db-list'; | ||
/** | ||
* Holds the cache options for cache store | ||
@@ -272,47 +267,1 @@ * | ||
} | ||
/** | ||
* Represents organization for a cache | ||
* | ||
* @export | ||
* @interface CacheSchema | ||
*/ | ||
export interface CacheSchema { | ||
/** | ||
* version number of cache, useful for upgrading | ||
* | ||
* @type {number} | ||
* @memberof CacheSchema | ||
*/ | ||
version: number; | ||
/** | ||
* name of the cache | ||
* | ||
* @type {string} | ||
* @memberof CacheSchema | ||
*/ | ||
name: string; | ||
/** | ||
* list of stores in the cache | ||
* | ||
* @type {{ [name: string]: CacheSchemaStore }} | ||
* @memberof CacheSchema | ||
*/ | ||
stores: Record<string, string>; | ||
} | ||
/** | ||
* item that is stored in cache | ||
* | ||
* @export | ||
* @interface CacheItem | ||
*/ | ||
export interface CacheItem { | ||
/** | ||
* date and time that item was retrieved from api/stored in cache | ||
* | ||
* @type {number} | ||
* @memberof CacheItem | ||
*/ | ||
timeCached?: number; | ||
} |
@@ -10,3 +10,5 @@ /** | ||
import { Providers } from '../providers/Providers'; | ||
import { CacheItem, CacheSchema, dbListKey } from './CacheService'; | ||
import { dbListKey } from './dbListKey'; | ||
import { CacheItem } from './CacheItem'; | ||
import { CacheSchema } from './CacheSchema'; | ||
@@ -13,0 +15,0 @@ /** |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
/** | ||
@@ -7,4 +8,3 @@ * ------------------------------------------------------------------------------------------- | ||
*/ | ||
import { it } from '@jest/globals'; | ||
import { expect } from '@open-wc/testing'; | ||
import { equals } from './equals'; | ||
@@ -22,34 +22,40 @@ | ||
it.each([ | ||
[{}, {}], | ||
[ | ||
{ a: 1, b: true, c: 'foo' }, | ||
{ c: 'foo', b: true, a: 1 } | ||
], | ||
[{ a: [1, 2, 3] }, { a: [1, 2, 3] }], | ||
[{ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [3]]] }], | ||
[circularObject, circularObject], | ||
[circularObject, { a: circularObject }], | ||
[circularArray, circularArray], | ||
[ | ||
{ a: circularObject, b: circularArray }, | ||
{ a: circularObject, b: circularArray } | ||
], | ||
[{ a: simpleDate }, { a: simpleDate }] | ||
])('should return true between %p and %p', (o1: unknown, o2: unknown) => { | ||
expect(equals(o1, o2)).toBe(true); | ||
it('should return true', () => { | ||
const testValues = [ | ||
[{}, {}], | ||
[ | ||
{ a: 1, b: true, c: 'foo' }, | ||
{ c: 'foo', b: true, a: 1 } | ||
], | ||
[{ a: [1, 2, 3] }, { a: [1, 2, 3] }], | ||
[{ a: { b: { c: 1 } } }, { a: { b: { c: 1 } } }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [3]]] }], | ||
[circularObject, circularObject], | ||
[circularObject, { a: circularObject }], | ||
[circularArray, circularArray], | ||
[ | ||
{ a: circularObject, b: circularArray }, | ||
{ a: circularObject, b: circularArray } | ||
], | ||
[{ a: simpleDate }, { a: simpleDate }] | ||
]; | ||
for (const [o1, o2] of testValues) { | ||
expect(equals(o1, o2)).to.be.true; | ||
} | ||
}); | ||
it.each([ | ||
[{ a: {} }, { a: [] }], | ||
[{ a: [1, 2, 3] }, { a: [3, 2, 1] }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [4]]] }], | ||
[{ a: { b: [{ c: 1 }, { d: [2, 3] }] } }, { a: { b: [{ c: 1 }, { d: [3, 2] }] } }], | ||
[{ a: new Date() }, { a: new Date() }], | ||
[circularObject, circularArray], | ||
[circularObject, { b: circularObject }] | ||
])('should return false between %p and %p', (o1: unknown, o2: unknown) => { | ||
expect(equals(o1, o2)).toBe(false); | ||
it('should return false ', () => { | ||
const testValues = [ | ||
[{ a: {} }, { a: [] }], | ||
[{ a: [1, 2, 3] }, { a: [3, 2, 1] }], | ||
[{ a: [1, [2, [3]]] }, { a: [1, [2, [4]]] }], | ||
[{ a: { b: [{ c: 1 }, { d: [2, 3] }] } }, { a: { b: [{ c: 1 }, { d: [3, 2] }] } }], | ||
[{ a: new Date() }, { a: new Date() }], | ||
[circularObject, circularArray], | ||
[circularObject, { b: circularObject }] | ||
]; | ||
for (const [o1, o2] of testValues) { | ||
expect(equals(o1, o2)).to.be.false; | ||
} | ||
}); | ||
}); |
@@ -8,31 +8,36 @@ /** | ||
import { it } from '@jest/globals'; | ||
import { assert } from 'console'; | ||
import { EventDispatcher } from './EventDispatcher'; | ||
import { assert, restore, fake } from 'sinon'; | ||
describe('EventDispatcher tests', () => { | ||
afterEach(() => { | ||
// Restore the default sandbox here | ||
restore(); | ||
}); | ||
it('should add and remove event handlers', () => { | ||
const dispatcher = new EventDispatcher(); | ||
const handler1 = jest.fn(); | ||
const handler2 = jest.fn(); | ||
const handler1 = fake(); | ||
const handler2 = fake(); | ||
dispatcher.add(handler1); | ||
dispatcher.add(handler2); | ||
dispatcher.fire('event'); | ||
expect(handler1).toHaveBeenCalledTimes(1); | ||
expect(handler2).toHaveBeenCalledTimes(1); | ||
assert.calledOnce(handler1); | ||
assert.calledOnce(handler2); | ||
dispatcher.remove(handler1); | ||
dispatcher.fire('event'); | ||
expect(handler1).toHaveBeenCalledTimes(1); | ||
expect(handler2).toHaveBeenCalledTimes(2); | ||
assert.calledOnce(handler1); | ||
assert.callCount(handler2, 2); | ||
}); | ||
it('should not throw when remove is called with an unregistered handler', () => { | ||
try { | ||
const dispatcher = new EventDispatcher(); | ||
const handler1 = jest.fn(); | ||
const handler1 = fake(); | ||
dispatcher.remove(handler1); | ||
} catch (e) { | ||
assert(false, 'should not throw'); | ||
assert.fail('should not throw'); | ||
} | ||
assert(true, 'did not throw'); | ||
assert.pass('did not throw'); | ||
}); | ||
}); |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
/** | ||
@@ -8,20 +9,24 @@ * ------------------------------------------------------------------------------------------- | ||
import { it } from '@jest/globals'; | ||
import { expect } from '@open-wc/testing'; | ||
import { fake } from 'sinon'; | ||
import { AuthenticationHandlerOptions, Middleware } from '@microsoft/microsoft-graph-client'; | ||
import { MockProvider } from '../mock/MockProvider'; | ||
import { Providers } from '../providers/Providers'; | ||
import { chainMiddleware, prepScopes, validateBaseURL } from './GraphHelpers'; | ||
import { chainMiddleware } from './chainMiddleware'; | ||
import { prepScopes } from './prepScopes'; | ||
import { validateBaseURL } from './validateBaseURL'; | ||
describe('GraphHelpers - prepScopes', () => { | ||
it('should return an empty array when incremental consent is disabled', () => { | ||
it('should return an empty array when incremental consent is disabled', async () => { | ||
const scopes = ['scope1', 'scope2']; | ||
Providers.globalProvider = new MockProvider(true); | ||
Providers.globalProvider.isIncrementalConsentDisabled = true; | ||
expect(prepScopes(...scopes)).toEqual([]); | ||
// eql for loose equality | ||
await expect(prepScopes(...scopes)).to.eql([]); | ||
}); | ||
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled', () => { | ||
it('should return an array of AuthenticationHandlerOptions when incremental consent is enabled', async () => { | ||
const scopes = ['scope1', 'scope2']; | ||
Providers.globalProvider = new MockProvider(true); | ||
Providers.globalProvider.isIncrementalConsentDisabled = false; | ||
expect(prepScopes(...scopes)).toEqual([new AuthenticationHandlerOptions(undefined, { scopes })]); | ||
await expect(prepScopes(...scopes)).to.eql([new AuthenticationHandlerOptions(undefined, { scopes })]); | ||
}); | ||
@@ -31,6 +36,6 @@ }); | ||
describe('GraphHelpers - chainMiddleware', () => { | ||
it('should return the first middleware when only one is passed', () => { | ||
const middleware: Middleware[] = [{ execute: jest.fn(), setNext: jest.fn() }]; | ||
it('should return the first middleware when only one is passed', async () => { | ||
const middleware: Middleware[] = [{ execute: fake(), setNext: fake() }]; | ||
const result = chainMiddleware(...middleware); | ||
expect(result).toEqual(middleware[0]); | ||
await expect(result).to.equal(middleware[0]); | ||
}); | ||
@@ -41,3 +46,3 @@ | ||
const result = chainMiddleware(...middleware); | ||
expect(result).toBeUndefined(); | ||
expect(result).to.be.undefined; | ||
}); | ||
@@ -48,7 +53,7 @@ it('should now throw when the middleware array is undefined', () => { | ||
const result = chainMiddleware(undefined); | ||
expect(result).toBeUndefined(); | ||
expect(result).to.be.undefined; | ||
} catch (e) { | ||
error = 'thrown and caught'; | ||
} | ||
expect(error).toBeUndefined(); | ||
expect(error).to.be.undefined; | ||
}); | ||
@@ -58,23 +63,27 @@ }); | ||
describe('GraphHelpers - validateBaseUrl', () => { | ||
it.each([ | ||
'https://graph.microsoft.com', | ||
'https://graph.microsoft.us', | ||
'https://dod-graph.microsoft.us', | ||
'https://graph.microsoft.de', | ||
'https://microsoftgraph.chinacloudapi.cn' | ||
])('should return %p as a valid base url', (graphUrl: string) => { | ||
expect(validateBaseURL(graphUrl)).toBe(graphUrl); | ||
it('should return as a valid Url', async () => { | ||
const validUrls = [ | ||
'https://graph.microsoft.com', | ||
'https://graph.microsoft.us', | ||
'https://dod-graph.microsoft.us', | ||
'https://graph.microsoft.de', | ||
'https://microsoftgraph.chinacloudapi.cn' | ||
]; | ||
for (const url of validUrls) { | ||
await expect(validateBaseURL(url)).to.equal(url); | ||
} | ||
}); | ||
it.each(['https://graph.microsoft.net', 'https://random.us', 'https://nope.cn'])( | ||
'should return undefined for %p as an invalid base url', | ||
(graphUrl: string) => { | ||
expect(validateBaseURL(graphUrl)).toBeUndefined(); | ||
it('should return undefeined for invalid Url', () => { | ||
const validUrls = ['https://graph.microsoft.net', 'https://random.us', 'https://nope.cn']; | ||
for (const url of validUrls) { | ||
expect(validateBaseURL(url)).to.be.undefined; | ||
} | ||
); | ||
it.each(['not a url', 'graph.microsoft.com'])( | ||
'should return undefined for when supplied a %p which is not a well formed url', | ||
(input: string) => { | ||
expect(validateBaseURL(input)).toBeUndefined(); | ||
}); | ||
it('should return undefined for when supplied a %p which is not a well formed url', () => { | ||
const testValues = ['not a url', 'graph.microsoft.com']; | ||
for (const test of testValues) { | ||
expect(validateBaseURL(test)).to.be.undefined; | ||
} | ||
); | ||
}); | ||
}); |
@@ -14,3 +14,3 @@ /** | ||
import { ComponentMiddlewareOptions } from './ComponentMiddlewareOptions'; | ||
import { validateBaseURL } from './GraphHelpers'; | ||
import { validateBaseURL } from './validateBaseURL'; | ||
@@ -17,0 +17,0 @@ /** |
@@ -11,2 +11,2 @@ /** | ||
export const PACKAGE_VERSION = '3.1.3-preview.4b85be1'; | ||
export const PACKAGE_VERSION = '3.1.3-preview.59cccb0'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
648457
223
9942
95
+ Added@lit/reactive-element@2.0.4(transitive)
+ Addedlit@3.2.1(transitive)
+ Addedlit-element@4.1.1(transitive)
+ Addedlit-html@3.2.1(transitive)
- Removed@lit/reactive-element@1.6.3(transitive)
- Removedlit@2.8.0(transitive)
- Removedlit-element@3.3.3(transitive)
- Removedlit-html@2.8.0(transitive)
Updatedlit@^3.0.0