mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#46 Moved test cases into test folder
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"tsc:w": "tsc -w",
|
"tsc:w": "tsc -w",
|
||||||
"typings": "typings",
|
"typings": "typings",
|
||||||
"test": "live-server --open=tests-runner.html"
|
"test": "live-server --open=index.html --entry-file=test/ "
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@@ -1,82 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2016 Alfresco Software, Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
System.register(['angular2/testing', 'angular2/core', 'angular2/http', 'angular2/http/testing', './upload.service'], function(exports_1, context_1) {
|
|
||||||
"use strict";
|
|
||||||
var __moduleName = context_1 && context_1.id;
|
|
||||||
var testing_1, core_1, http_1, testing_2, upload_service_1;
|
|
||||||
return {
|
|
||||||
setters:[
|
|
||||||
function (testing_1_1) {
|
|
||||||
testing_1 = testing_1_1;
|
|
||||||
},
|
|
||||||
function (core_1_1) {
|
|
||||||
core_1 = core_1_1;
|
|
||||||
},
|
|
||||||
function (http_1_1) {
|
|
||||||
http_1 = http_1_1;
|
|
||||||
},
|
|
||||||
function (testing_2_1) {
|
|
||||||
testing_2 = testing_2_1;
|
|
||||||
},
|
|
||||||
function (upload_service_1_1) {
|
|
||||||
upload_service_1 = upload_service_1_1;
|
|
||||||
}],
|
|
||||||
execute: function() {
|
|
||||||
testing_1.describe('AlfrescoUploadService', function () {
|
|
||||||
var injector, backend, mockBackend, httpService, service, options;
|
|
||||||
beforeEach(function () {
|
|
||||||
injector = core_1.Injector.resolveAndCreate([
|
|
||||||
http_1.HTTP_PROVIDERS,
|
|
||||||
testing_2.MockBackend,
|
|
||||||
core_1.provide(http_1.XHRBackend, { useClass: testing_2.MockBackend })
|
|
||||||
]);
|
|
||||||
mockBackend = injector.get(testing_2.MockBackend);
|
|
||||||
backend = injector.get(http_1.XHRBackend);
|
|
||||||
httpService = injector.get(http_1.Http);
|
|
||||||
options = {
|
|
||||||
url: '',
|
|
||||||
withCredentials: true,
|
|
||||||
authToken: btoa('fakeadmin:fakeadmin'),
|
|
||||||
authTokenPrefix: 'Basic',
|
|
||||||
fieldName: 'fakeFileData',
|
|
||||||
formFields: {
|
|
||||||
siteid: 'fakeSite',
|
|
||||||
containerid: 'fakeFolder'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
service = new upload_service_1.UploadService(options);
|
|
||||||
});
|
|
||||||
testing_1.it('should make XHR request', function () {
|
|
||||||
var xhr = {
|
|
||||||
open: jasmine.createSpy('open'),
|
|
||||||
upload: jasmine.createSpy('upload'),
|
|
||||||
send: jasmine.createSpy('send'),
|
|
||||||
setRequestHeader: jasmine.createSpy('setRequestHeader')
|
|
||||||
};
|
|
||||||
XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
|
|
||||||
XMLHttpRequest.and.callFake(function () {
|
|
||||||
return xhr;
|
|
||||||
});
|
|
||||||
var filesFake = [{ name: 'fake-name', size: 10 }];
|
|
||||||
service.addToQueue(filesFake);
|
|
||||||
expect(xhr.open).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=upload.service.spec.js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E,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC;qBAC1D,CAAC;oBAEF,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;oBACrD,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;wBACxB,MAAM,CAAC,GAAG,CAAC;oBACf,CAAC,CAAC,CAAC;oBAEH,IAAI,SAAS,GAAG,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC,CAAC;oBAChD,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAE9B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;gBACxC,CAAC,CAAC,CAAC;YAIP,CAAC,CAAC,CAAC"}
|
|
3
ng2-components/ng2-alfresco-upload/test/.gitignore
vendored
Normal file
3
ng2-components/ng2-alfresco-upload/test/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*.js
|
||||||
|
*.js.map
|
||||||
|
*.d.ts
|
54
ng2-components/ng2-alfresco-upload/test/index.html
Normal file
54
ng2-components/ng2-alfresco-upload/test/index.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<base href="/">
|
||||||
|
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||||
|
<title>Alfresco Upload component Tests</title>
|
||||||
|
<link rel="stylesheet" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
|
||||||
|
<script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
|
||||||
|
<script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
|
||||||
|
<script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
|
||||||
|
|
||||||
|
<!-- #1. add the system.js library -->
|
||||||
|
<script src="../node_modules/es6-shim/es6-shim.min.js"></script>
|
||||||
|
<script src="../node_modules/systemjs/dist/system-polyfills.js"></script>
|
||||||
|
<script src="../node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
|
||||||
|
<script src="../node_modules/angular2/bundles/angular2-polyfills.js"></script>
|
||||||
|
<script src="../node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
<script src="../node_modules/rxjs/bundles/Rx.js"></script>
|
||||||
|
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
|
||||||
|
|
||||||
|
<script src="../node_modules/angular2/bundles/http.dev.js"></script>
|
||||||
|
<script src="../node_modules/angular2/bundles/router.dev.js"></script>
|
||||||
|
<script src="../node_modules/angular2/bundles/testing.dev.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// #2. Configure systemjs to use the .js extension
|
||||||
|
// for imports from the app folder
|
||||||
|
System.config({
|
||||||
|
packages: {
|
||||||
|
'test': {defaultExtension: 'js'},
|
||||||
|
'src': {defaultExtension: 'js'}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// #3. Import the spec file explicitly
|
||||||
|
Promise.all([
|
||||||
|
System.import('test/services/upload.service.spec')
|
||||||
|
])
|
||||||
|
// #4. wait for all imports to load ...
|
||||||
|
// then re-execute `window.onload` which
|
||||||
|
// triggers the Jasmine test-runner start
|
||||||
|
// or explain what went wrong.
|
||||||
|
.then(window.onload)
|
||||||
|
.catch(console.error.bind(console));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Unit Testing Chapter #1: Proof of life. -->
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -15,11 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {it, describe} from 'angular2/testing';
|
import {it, describe, beforeEach, expect} from 'angular2/testing';
|
||||||
import {provide, Injector} from 'angular2/core';
|
import {provide, Injector} from 'angular2/core';
|
||||||
import {Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions} from 'angular2/http';
|
import {Http, HTTP_PROVIDERS, XHRBackend} from 'angular2/http';
|
||||||
import {MockBackend} from 'angular2/http/testing';
|
import {MockBackend} from 'angular2/http/testing';
|
||||||
import {UploadService} from './upload.service';
|
import {UploadService} from '../../src/services/upload.service';
|
||||||
|
|
||||||
describe('AlfrescoUploadService', () => {
|
describe('AlfrescoUploadService', () => {
|
||||||
let injector,
|
let injector,
|
||||||
@@ -56,11 +56,12 @@ describe('AlfrescoUploadService', () => {
|
|||||||
|
|
||||||
it('should make XHR request', () => {
|
it('should make XHR request', () => {
|
||||||
|
|
||||||
var xhr = {
|
let xhr = {
|
||||||
open: jasmine.createSpy('open'),
|
open: jasmine.createSpy('open'),
|
||||||
upload: jasmine.createSpy('upload'),
|
upload: jasmine.createSpy('upload'),
|
||||||
send: jasmine.createSpy('send'),
|
send: jasmine.createSpy('send'),
|
||||||
setRequestHeader: jasmine.createSpy('setRequestHeader')
|
setRequestHeader: jasmine.createSpy('setRequestHeader'),
|
||||||
|
onprogress : jasmine.createSpy('onprogress')
|
||||||
};
|
};
|
||||||
|
|
||||||
XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
|
XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
|
||||||
@@ -76,4 +77,4 @@ describe('AlfrescoUploadService', () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
15
ng2-components/ng2-alfresco-upload/test/tsconfig.json
Normal file
15
ng2-components/ng2-alfresco-upload/test/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "system",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"removeComments": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"declaration": false
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
]
|
||||||
|
}
|
@@ -1,52 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
||||||
<title>Alfresco Login component Tests</title>
|
|
||||||
<link rel="stylesheet" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
|
|
||||||
<script src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
|
|
||||||
<script src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
|
|
||||||
<script src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
|
|
||||||
|
|
||||||
<!-- #1. add the system.js library -->
|
|
||||||
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
|
|
||||||
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
|
|
||||||
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
|
|
||||||
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
|
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
|
||||||
<script src="node_modules/rxjs/bundles/Rx.js"></script>
|
|
||||||
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
|
|
||||||
|
|
||||||
<script src="node_modules/angular2/bundles/http.dev.js"></script>
|
|
||||||
<script src="node_modules/angular2/bundles/router.dev.js"></script>
|
|
||||||
<script src="node_modules/angular2/bundles/testing.dev.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// #2. Configure systemjs to use the .js extension
|
|
||||||
// for imports from the app folder
|
|
||||||
System.config({
|
|
||||||
packages: {
|
|
||||||
'src': {defaultExtension: 'js'}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// #3. Import the spec file explicitly
|
|
||||||
Promise.all([
|
|
||||||
System.import('src/services/upload.service.spec')
|
|
||||||
])
|
|
||||||
// #4. wait for all imports to load ...
|
|
||||||
// then re-execute `window.onload` which
|
|
||||||
// triggers the Jasmine test-runner start
|
|
||||||
// or explain what went wrong.
|
|
||||||
.then(window.onload)
|
|
||||||
.catch(console.error.bind(console));
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<!-- Unit Testing Chapter #1: Proof of life. -->
|
|
||||||
<script>
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Reference in New Issue
Block a user