mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
back to mocha, working in future node versions
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"extensions": ["ts"],
|
|
||||||
"spec": ["lib/js-api/test/**/*.spec.ts"],
|
|
||||||
"node-option": [
|
|
||||||
"loader=ts-node/register"
|
|
||||||
]
|
|
||||||
}
|
|
4
lib/js-api/.mocharc.json
Normal file
4
lib/js-api/.mocharc.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extensions": ["ts"],
|
||||||
|
"spec": ["dist/tmp/libs/js-api/test/**/*.spec.js"]
|
||||||
|
}
|
@@ -16,6 +16,15 @@
|
|||||||
"externalBuildTargets": [
|
"externalBuildTargets": [
|
||||||
"build"
|
"build"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"test": {
|
||||||
|
"outputPath": "dist/tmp/libs/js-api",
|
||||||
|
"tsConfig": "lib/js-api/tsconfig.spec.json",
|
||||||
|
"assets": [
|
||||||
|
"lib/js-api/test/mockObjects/assets/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"publish": {
|
"publish": {
|
||||||
@@ -33,11 +42,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"executor": "@nrwl/jest:jest",
|
"executor": "nx:run-commands",
|
||||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||||
"options": {
|
"options": {
|
||||||
"jestConfig": "lib/js-api/jest.config.ts",
|
"commands": [
|
||||||
"passWithNoTests": true
|
"nx run js-api:build:test",
|
||||||
|
"mocha --full-trace --config lib/js-api/.mocharc.json",
|
||||||
|
"rm -fr dist/tmp/libs/js-api"
|
||||||
|
],
|
||||||
|
"parallel": false
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"ci": {
|
"ci": {
|
||||||
|
@@ -18,8 +18,6 @@
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { AlfrescoApi, ContentApi, Oauth2Auth } from '../src';
|
import { AlfrescoApi, ContentApi, Oauth2Auth } from '../src';
|
||||||
import { EcmAuthMock, OAuthMock } from './mockObjects';
|
import { EcmAuthMock, OAuthMock } from './mockObjects';
|
||||||
import { TextEncoder, TextDecoder } from 'util';
|
|
||||||
Object.assign(global, { TextDecoder, TextEncoder });
|
|
||||||
import jsdom from 'jsdom';
|
import jsdom from 'jsdom';
|
||||||
|
|
||||||
const { JSDOM } = jsdom;
|
const { JSDOM } = jsdom;
|
||||||
@@ -171,6 +169,7 @@ describe('Oauth2 test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should refresh token when the login not use the implicitFlow ', function (done) {
|
it('should refresh token when the login not use the implicitFlow ', function (done) {
|
||||||
|
this.timeout(3000);
|
||||||
oauth2Mock.get200Response();
|
oauth2Mock.get200Response();
|
||||||
|
|
||||||
const oauth2Auth = new Oauth2Auth(
|
const oauth2Auth = new Oauth2Auth(
|
||||||
@@ -203,9 +202,10 @@ describe('Oauth2 test', () => {
|
|||||||
}, 600);
|
}, 600);
|
||||||
|
|
||||||
oauth2Auth.login('admin', 'admin');
|
oauth2Auth.login('admin', 'admin');
|
||||||
}, 3000);
|
});
|
||||||
|
|
||||||
it('should not hang the app also if teh logout is missing', function (done) {
|
it('should not hang the app also if teh logout is missing', function (done) {
|
||||||
|
this.timeout(3000);
|
||||||
oauth2Mock.get200Response();
|
oauth2Mock.get200Response();
|
||||||
|
|
||||||
const oauth2Auth = new Oauth2Auth(
|
const oauth2Auth = new Oauth2Auth(
|
||||||
@@ -237,7 +237,7 @@ describe('Oauth2 test', () => {
|
|||||||
}, 600);
|
}, 600);
|
||||||
|
|
||||||
oauth2Auth.login('admin', 'admin');
|
oauth2Auth.login('admin', 'admin');
|
||||||
}, 3000);
|
});
|
||||||
|
|
||||||
it('should emit a token_issued event if login is ok ', (done) => {
|
it('should emit a token_issued event if login is ok ', (done) => {
|
||||||
oauth2Mock.get200Response();
|
oauth2Mock.get200Response();
|
||||||
@@ -426,6 +426,7 @@ describe('Oauth2 test', () => {
|
|||||||
// TODO: very flaky test, fails on different machines if running slow, might relate to `this.timeout`
|
// TODO: very flaky test, fails on different machines if running slow, might relate to `this.timeout`
|
||||||
// eslint-disable-next-line ban/ban
|
// eslint-disable-next-line ban/ban
|
||||||
xit('should extend content session after oauth token refresh', function (done) {
|
xit('should extend content session after oauth token refresh', function (done) {
|
||||||
|
this.timeout(3000);
|
||||||
|
|
||||||
oauth2Mock.get200Response();
|
oauth2Mock.get200Response();
|
||||||
authResponseMock.get200ValidTicket();
|
authResponseMock.get200ValidTicket();
|
||||||
@@ -463,8 +464,9 @@ describe('Oauth2 test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
alfrescoApi.login('admin', 'admin');
|
alfrescoApi.login('admin', 'admin');
|
||||||
|
this.timeout(3000);
|
||||||
alfrescoApi.refreshToken();
|
alfrescoApi.refreshToken();
|
||||||
}, 3000);
|
});
|
||||||
|
|
||||||
it('isLoggedIn should return true if the api is logged in', (done) => {
|
it('isLoggedIn should return true if the api is logged in', (done) => {
|
||||||
oauth2Mock.get200Response();
|
oauth2Mock.get200Response();
|
||||||
|
@@ -53,7 +53,13 @@ describe('Oauth2 Implicit flow test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should redirect to login if access token is not valid', (done) => {
|
it('should redirect to login if access token is not valid', (done) => {
|
||||||
window = globalAny.window = { location: {} };
|
window = globalAny.window = {
|
||||||
|
location: {
|
||||||
|
assign: (v: any) => {
|
||||||
|
window.location.href = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
globalAny.document = {
|
globalAny.document = {
|
||||||
getElementById: () => ''
|
getElementById: () => ''
|
||||||
};
|
};
|
||||||
@@ -81,7 +87,13 @@ describe('Oauth2 Implicit flow test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not loop over redirection when redirectUri contains hash and token is not valid ', (done) => {
|
it('should not loop over redirection when redirectUri contains hash and token is not valid ', (done) => {
|
||||||
window = globalAny.window = { location: {} };
|
window = globalAny.window = {
|
||||||
|
location: {
|
||||||
|
assign: (v: any) => {
|
||||||
|
window.location.href = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
globalAny.document = {
|
globalAny.document = {
|
||||||
getElementById: () => ''
|
getElementById: () => ''
|
||||||
};
|
};
|
||||||
@@ -112,7 +124,13 @@ describe('Oauth2 Implicit flow test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not redirect to login if access token is valid', (done) => {
|
it('should not redirect to login if access token is valid', (done) => {
|
||||||
window = globalAny.window = { location: {} };
|
window = globalAny.window = {
|
||||||
|
location: {
|
||||||
|
assign: (v: any) => {
|
||||||
|
window.location.href = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
globalAny.document = {
|
globalAny.document = {
|
||||||
getElementById: () => ''
|
getElementById: () => ''
|
||||||
};
|
};
|
||||||
@@ -144,11 +162,17 @@ describe('Oauth2 Implicit flow test', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set the loginFragment to redirect after the login if it is present', (done) => {
|
it('should set the loginFragment to redirect after the login if it is present', (done) => {
|
||||||
window = globalAny.window = {};
|
window = globalAny.window = {
|
||||||
|
location: {
|
||||||
|
assign: (v: any) => {
|
||||||
|
window.location.href = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
globalAny.document = {
|
globalAny.document = {
|
||||||
getElementById: () => ''
|
getElementById: () => ''
|
||||||
};
|
};
|
||||||
window.location = <Location>{ hash: 'asfasfasfa' };
|
window.location.hash = 'asfasfasfa';
|
||||||
|
|
||||||
Object.defineProperty(window.location, 'hash', {
|
Object.defineProperty(window.location, 'hash', {
|
||||||
writable: true,
|
writable: true,
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true
|
||||||
"types": ["jest"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
{
|
{
|
||||||
"extends": "./tsconfig.json",
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../../dist/out-tsc",
|
"module": "CommonJS",
|
||||||
"module": "commonjs",
|
"moduleResolution": "node",
|
||||||
"types": ["jest", "node", "@types/jest"]
|
"target": "ES2015",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"skipDefaultLibCheck": true,
|
||||||
|
"types": ["mocha"]
|
||||||
},
|
},
|
||||||
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
|
"exclude": [],
|
||||||
|
"include": ["**/*"]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user