зеркало из https://github.com/microsoft/paris.git
Replace mocha + karma + chai with jest
This commit is contained in:
Родитель
4a4b6a7dbf
Коммит
f1cc7c2c46
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"cSpell.words": [
|
||||
"repo",
|
||||
"todolist"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import 'reflect-metadata';
|
||||
|
||||
global['Reflect'] = Reflect;
|
135
karma.conf.js
135
karma.conf.js
|
@ -1,135 +0,0 @@
|
|||
// Karma configuration
|
||||
// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time)
|
||||
'use strict';
|
||||
|
||||
var argv = require('yargs').argv;
|
||||
var minimatch = require("minimatch");
|
||||
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: './',
|
||||
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
// Polyfills.
|
||||
'node_modules/core-js/client/shim.min.js',
|
||||
'node_modules/intl/dist/Intl.min.js',
|
||||
|
||||
'node_modules/traceur/bin/traceur.js',
|
||||
|
||||
// System.js for module loading
|
||||
'node_modules/systemjs/dist/system.src.js',
|
||||
|
||||
// Zone.js dependencies
|
||||
'node_modules/zone.js/dist/zone.js',
|
||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||
'node_modules/zone.js/dist/async-test.js',
|
||||
'node_modules/zone.js/dist/fake-async-test.js',
|
||||
'node_modules/zone.js/dist/sync-test.js',
|
||||
'node_modules/zone.js/dist/proxy.js',
|
||||
'node_modules/zone.js/dist/jasmine-patch.js',
|
||||
|
||||
// RxJs.
|
||||
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
||||
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
|
||||
|
||||
// paths loaded via module imports
|
||||
// Angular itself
|
||||
{ pattern: 'node_modules/@angular/**/*.js', included: false, watched: true },
|
||||
{ pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false },
|
||||
|
||||
'test-config.js',
|
||||
{ pattern: 'dist/dev/system-config.js', watched: true, included: true },
|
||||
|
||||
{ pattern: 'dist/dev/**/*.js', included: false, watched: true },
|
||||
{ pattern: 'dist/dev/**/*.html', included: false, watched: true, served: true },
|
||||
{ pattern: 'dist/dev/**/*.css', included: false, watched: true, served: true },
|
||||
|
||||
// suppress annoying 404 warnings for resources, images, etc.
|
||||
{ pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },
|
||||
|
||||
'test-main.js'
|
||||
],
|
||||
|
||||
// must go along with above, suppress annoying 404 warnings.
|
||||
proxies: {
|
||||
'/assets/': '/base/dist/dev/assets/'
|
||||
},
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
'node_modules/**/*spec.js'
|
||||
],
|
||||
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
|
||||
// test items reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['mocha'],
|
||||
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: [
|
||||
'Chrome'
|
||||
],
|
||||
|
||||
|
||||
customLaunchers: {
|
||||
Chrome_travis_ci: {
|
||||
base: 'Chrome',
|
||||
flags: ['--no-sandbox']
|
||||
}
|
||||
},
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false,
|
||||
|
||||
// Passing command line arguments to tests
|
||||
client: {
|
||||
files: argv.files ? minimatch.makeRe(argv.files).source : null
|
||||
}
|
||||
});
|
||||
|
||||
if (process.env.APPVEYOR) {
|
||||
config.browsers = ['IE'];
|
||||
config.singleRun = true;
|
||||
config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough
|
||||
}
|
||||
|
||||
if (process.env.TRAVIS || process.env.CIRCLECI) {
|
||||
config.browsers = ['Chrome_travis_ci'];
|
||||
config.singleRun = true;
|
||||
config.browserNoActivityTimeout = 90000;
|
||||
}
|
||||
};
|
|
@ -1,60 +1,59 @@
|
|||
import "reflect-metadata"
|
||||
import * as chai from 'chai';
|
||||
import '../services/paris.init.spec';
|
||||
import {DataSet} from "../dataset/dataset";
|
||||
import {parseDataSet} from "./data-to-model";
|
||||
import 'reflect-metadata';
|
||||
import { DataSet } from '../dataset/dataset';
|
||||
import { parseDataSet } from './data-to-model';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
const rawDataSet:RawDataSet = {
|
||||
const rawDataSet: RawDataSet = {
|
||||
results: [
|
||||
{
|
||||
id: 1,
|
||||
name: "First"
|
||||
name: 'First',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Seconds"
|
||||
}
|
||||
name: 'Seconds',
|
||||
},
|
||||
],
|
||||
$next: '/api/todolist?page=2',
|
||||
total: 123
|
||||
total: 123,
|
||||
};
|
||||
|
||||
describe('Raw data -> model', () => {
|
||||
describe('Create a DataSet', () => {
|
||||
let dataSet:DataSet<SimpleEntity>;
|
||||
let dataSet: DataSet<SimpleEntity>;
|
||||
|
||||
before(() => {
|
||||
console.log("REFLECT", Reflect);
|
||||
dataSet = parseDataSet<SimpleEntity, RawDataSet>(rawDataSet, 'results', parseRawDataSet);
|
||||
beforeAll(() => {
|
||||
dataSet = parseDataSet<SimpleEntity, RawDataSet>(
|
||||
rawDataSet,
|
||||
'results',
|
||||
parseRawDataSet
|
||||
);
|
||||
});
|
||||
|
||||
it('has items', () => {
|
||||
expect(dataSet.items.length).to.equal(rawDataSet.results.length);
|
||||
expect(dataSet.items.length).toEqual(rawDataSet.results.length);
|
||||
});
|
||||
|
||||
it('has a next property', () => {
|
||||
expect(dataSet.next).to.equal(rawDataSet.$next);
|
||||
})
|
||||
expect(dataSet.next).toEqual(rawDataSet.$next);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function parseRawDataSet(rawDataSet:RawDataSet):DataSet<SimpleEntity>{
|
||||
function parseRawDataSet(rawDataSet: RawDataSet): DataSet<SimpleEntity> {
|
||||
return {
|
||||
items: rawDataSet.results,
|
||||
next: rawDataSet.$next,
|
||||
count: rawDataSet.total
|
||||
}
|
||||
count: rawDataSet.total,
|
||||
};
|
||||
}
|
||||
|
||||
interface SimpleEntity{
|
||||
id:number,
|
||||
name:string
|
||||
interface SimpleEntity {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface RawDataSet {
|
||||
results: Array<SimpleEntity>,
|
||||
$next: string,
|
||||
total: number
|
||||
results: Array<SimpleEntity>;
|
||||
$next: string;
|
||||
total: number;
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import "reflect-metadata";
|
||||
|
||||
(<any>global)['Reflect'] = Reflect;
|
|
@ -1,19 +1,11 @@
|
|||
import * as chaiSpies from 'chai-spies';
|
||||
import 'mocha';
|
||||
import "reflect-metadata"
|
||||
import * as chai from 'chai';
|
||||
import {Paris} from "./paris";
|
||||
import {Todo} from "../mock/todo.entity";
|
||||
import {Observable} from "rxjs";
|
||||
import {Repository} from "../repository/repository";
|
||||
import {DataEntityType, DataQuery} from "../main";
|
||||
import {DataOptions, defaultDataOptions} from "../dataset/data.options";
|
||||
import {Http} from "./http.service";
|
||||
import {CreateTodoListApiCall} from "../mock/create-new-list.api-call";
|
||||
import {of} from "rxjs/internal/observable/of";
|
||||
|
||||
chai.use(chaiSpies);
|
||||
const expect = chai.expect;
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { DataOptions, defaultDataOptions } from '../dataset/data.options';
|
||||
import { DataEntityType, DataQuery } from '../main';
|
||||
import { CreateTodoListApiCall } from '../mock/create-new-list.api-call';
|
||||
import { Todo } from '../mock/todo.entity';
|
||||
import { Repository } from '../repository/repository';
|
||||
import { Http } from './http.service';
|
||||
import { Paris } from './paris';
|
||||
|
||||
describe('Paris main', () => {
|
||||
let paris: Paris;
|
||||
|
@ -27,63 +19,69 @@ describe('Paris main', () => {
|
|||
});
|
||||
|
||||
it('should create a ToDo repository', () => {
|
||||
expect(repo).to.exist;
|
||||
expect(repo).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return a Repository from getRepository', () => {
|
||||
expect(repo instanceof Repository).to.be.true;
|
||||
expect(repo).toBeInstanceOf(Repository);
|
||||
});
|
||||
|
||||
xit('should return null if entity doesn\'t exist', () => {
|
||||
});
|
||||
it.skip("should return null if entity doesn't exist", () => {});
|
||||
});
|
||||
|
||||
describe('Get Todo item by ID', () => {
|
||||
let repo: Repository<Todo>,
|
||||
item$: Observable<Todo>;
|
||||
let repo: Repository<Todo>, item$: Observable<Todo>;
|
||||
let httpRequestSpy: jest.SpyInstance<Http>;
|
||||
|
||||
before(() => {
|
||||
chai.spy.on(Http, 'request');
|
||||
beforeAll(() => {
|
||||
httpRequestSpy = jest.spyOn(Http, 'request');
|
||||
});
|
||||
|
||||
after(() => {
|
||||
chai.spy.restore(Http);
|
||||
afterAll(() => {
|
||||
httpRequestSpy.mockRestore();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
repo = paris.getRepository(Todo);
|
||||
chai.spy.on(repo, 'getItemById');
|
||||
chai.spy.on(paris.dataStore, 'request');
|
||||
|
||||
jest.spyOn(repo, 'getItemById');
|
||||
jest.spyOn(paris.dataStore, 'request');
|
||||
item$ = paris.getItemById(Todo, 1);
|
||||
});
|
||||
|
||||
it('should call Repository.getItemById with correct default params', () => {
|
||||
expect(repo.getItemById).to.have.been.called.with(1, defaultDataOptions, undefined)
|
||||
expect(repo.getItemById).toHaveBeenCalledWith(1, defaultDataOptions, undefined);
|
||||
});
|
||||
|
||||
it('should call Http.request with correct default params', () => {
|
||||
expect(Http.request).to.have.been.called.with('GET', '/todo/1', undefined, {timeout: 20000});
|
||||
expect(Http.request).toHaveBeenCalledWith('GET', '/todo/1', undefined, {
|
||||
timeout: 20000,
|
||||
});
|
||||
});
|
||||
|
||||
it('should call Repository.getItemById with correct params', () => {
|
||||
paris.getItemById(Todo, 1, null, {test: 1});
|
||||
expect(repo.getItemById).to.have.been.called.with(1, defaultDataOptions, {test: 1})
|
||||
paris.getItemById(Todo, 1, null, { test: 1 });
|
||||
expect(repo.getItemById).toHaveBeenCalledWith(1, defaultDataOptions, { test: 1 });
|
||||
});
|
||||
|
||||
it('should call Http.request with correct params', () => {
|
||||
expect(Http.request).to.have.been.called.with('GET', '/todo/1', {params: {test: 1}}, {timeout: 20000});
|
||||
expect(Http.request).toHaveBeenCalledWith(
|
||||
'GET',
|
||||
'/todo/1',
|
||||
{ params: { test: 1 } },
|
||||
{ timeout: 20000 }
|
||||
);
|
||||
});
|
||||
|
||||
it('should return an Observable from paris.getItemById', () => {
|
||||
expect(item$ instanceof Observable).to.be.true;
|
||||
expect(item$).toBeInstanceOf(Observable);
|
||||
});
|
||||
|
||||
xit('should throw error if getItem is not supported', () => {
|
||||
});
|
||||
it.skip('should throw error if getItem is not supported', () => {});
|
||||
|
||||
it('should call datastore.request', () => {
|
||||
expect(paris.dataStore.request).to.have.been.called();
|
||||
expect(paris.dataStore.request).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -93,12 +91,10 @@ describe('Paris main', () => {
|
|||
});
|
||||
|
||||
it('should return the entityConfig for Todo', () => {
|
||||
expect(paris.getModelBaseConfig(Todo)).to.be.equal((<DataEntityType>Todo).entityConfig)
|
||||
expect(paris.getModelBaseConfig(Todo)).toEqual((<DataEntityType>Todo).entityConfig);
|
||||
});
|
||||
|
||||
xit('should return the valueObjectConfig for a value-object', () => {
|
||||
})
|
||||
|
||||
it.skip('should return the valueObjectConfig for a value-object', () => {});
|
||||
});
|
||||
|
||||
describe('query', () => {
|
||||
|
@ -107,262 +103,185 @@ describe('Paris main', () => {
|
|||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
repo = paris.getRepository(Todo);
|
||||
chai.spy.on(repo, 'query');
|
||||
jest.spyOn(repo, 'query');
|
||||
});
|
||||
|
||||
it('should call Repository.query with correct default params', () => {
|
||||
paris.query(Todo);
|
||||
expect(repo.query).to.have.been.called.with(undefined, defaultDataOptions)
|
||||
expect(repo.query).toHaveBeenCalledWith(undefined, defaultDataOptions);
|
||||
});
|
||||
|
||||
it('should call Repository.query with correct params', () => {
|
||||
const query: DataQuery = {where: {a: 1}},
|
||||
dataOptions: DataOptions = {allowCache: false};
|
||||
const query: DataQuery = { where: { a: 1 } },
|
||||
dataOptions: DataOptions = { allowCache: false };
|
||||
paris.query(Todo, query, dataOptions);
|
||||
expect(repo.query).to.have.been.called.with(query, dataOptions)
|
||||
expect(repo.query).toHaveBeenCalledWith(query, dataOptions);
|
||||
});
|
||||
|
||||
it('should return an Observable from paris.query', () => {
|
||||
expect(paris.query(Todo) instanceof Observable).to.be.true;
|
||||
expect(paris.query(Todo)).toBeInstanceOf(Observable);
|
||||
});
|
||||
|
||||
it('should throw error if repo doesn\'t exist', () => {
|
||||
expect(() => paris.query(<any>String)).to.throw()
|
||||
it("should throw error if repo doesn't exist", () => {
|
||||
expect(() => paris.query(<any>String)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('apiCall', () => {
|
||||
before(() => {
|
||||
chai.spy.on(Http, "request");
|
||||
let httpRequestSpy: jest.SpyInstance<Http>;
|
||||
let jestGetApiCallCacheSpy: jest.SpyInstance<Paris>;
|
||||
let jestMakeApiCallSpy: jest.SpyInstance<Paris>;
|
||||
|
||||
beforeAll(() => {
|
||||
httpRequestSpy = jest.spyOn(Http, 'request');
|
||||
});
|
||||
|
||||
after(() => {
|
||||
chai.spy.restore(Http);
|
||||
afterAll(() => {
|
||||
httpRequestSpy.mockRestore();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
chai.spy.on(paris, "getApiCallCache");
|
||||
chai.spy.on(paris, "makeApiCall");
|
||||
|
||||
jestGetApiCallCacheSpy = jest.spyOn(paris, 'getApiCallCache' as any);
|
||||
jestMakeApiCallSpy = jest.spyOn(paris, 'makeApiCall' as any);
|
||||
});
|
||||
|
||||
xit('should add data to cache if configured to', () => {
|
||||
it.skip('should add data to cache if configured to', () => {
|
||||
// TODO: we need to subscribe in order for this to work
|
||||
});
|
||||
|
||||
it('should get data from cache if available and configured to', () => {
|
||||
chai.spy.restore(paris, "getApiCallCache");
|
||||
const fakeCache = {get: () => of(null)};
|
||||
chai.spy.on(fakeCache, "get");
|
||||
chai.spy.on(paris, "getApiCallCache", () => fakeCache);
|
||||
jestGetApiCallCacheSpy.mockRestore();
|
||||
const fakeCache = { get: () => of(null) };
|
||||
jest.spyOn(fakeCache, 'get');
|
||||
paris['getApiCallCache'] = jest.fn(() => fakeCache);
|
||||
|
||||
paris.apiCall(CreateTodoListApiCall);
|
||||
expect((<any>paris).makeApiCall).to.not.have.been.called();
|
||||
expect(Http.request).to.not.have.been.called();
|
||||
expect(fakeCache.get).to.have.been.called();
|
||||
expect((<any>paris).makeApiCall).not.toHaveBeenCalled();
|
||||
expect(Http.request).not.toHaveBeenCalled();
|
||||
expect(fakeCache.get).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not get data from cache if allowCache is false', () => {
|
||||
paris.apiCall(CreateTodoListApiCall, undefined, {allowCache: false});
|
||||
expect((<any>paris).getApiCallCache).to.not.have.been.called();
|
||||
|
||||
paris.apiCall(CreateTodoListApiCall, undefined, { allowCache: false });
|
||||
expect((<any>paris).getApiCallCache).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should always add newer data to cache if cache exists', () => {
|
||||
it('should always add newer data to cache if cache exists', () => {});
|
||||
|
||||
it('should not cache null/undefined values', () => {});
|
||||
|
||||
it('should call makeApiCall with correct params', () => {});
|
||||
|
||||
it('should call makeApiCall with correct default params', () => {});
|
||||
|
||||
it('should emit from error$ if encountered an error', () => {});
|
||||
|
||||
it('should call modelArray if repo exists data is array', () => {});
|
||||
|
||||
it('should call createItem if repo exists and data is not an array', () => {});
|
||||
|
||||
it("should call DataTransformersService.parse if repo doesn't exist and data type is defined", () => {});
|
||||
|
||||
it('should call parse if defined', () => {});
|
||||
|
||||
it('should return an Observable', () => {});
|
||||
|
||||
it('should throw an error if no endpoint is configured', () => {});
|
||||
|
||||
it('should throw an error if no endpoint is configured', () => {});
|
||||
|
||||
it.skip('should call datastore.request', () => {
|
||||
expect(paris.dataStore.request).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not cache null/undefined values', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call makeApiCall with correct params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call makeApiCall with correct default params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should emit from error$ if encountered an error', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call modelArray if repo exists data is array', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call createItem if repo exists and data is not an array', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call DataTransformersService.parse if repo doesn\'t exist and data type is defined', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call parse if defined', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return an Observable', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should throw an error if no endpoint is configured', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should throw an error if no endpoint is configured', () => {
|
||||
|
||||
});
|
||||
|
||||
xit('should call datastore.request', () => {
|
||||
expect(paris.dataStore.request).to.have.been.called();
|
||||
});
|
||||
|
||||
it('should call Http.request with correct default params', () => {
|
||||
});
|
||||
|
||||
it('should call Http.request with correct params', () => {
|
||||
});
|
||||
it('should call Http.request with correct default params', () => {});
|
||||
|
||||
it('should call Http.request with correct params', () => {});
|
||||
});
|
||||
|
||||
xdescribe('callQuery', () => {
|
||||
describe('callQuery', () => {
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
});
|
||||
it('should call makeApiCall with correct params', () => {
|
||||
it('should call makeApiCall with correct params', () => {});
|
||||
|
||||
it('should call makeApiCall with correct default params', () => {});
|
||||
|
||||
it('should call rawDataToDataSet with correct params', () => {});
|
||||
|
||||
it('should emit from error$ if encountered an error', () => {});
|
||||
|
||||
it('should return an Observable', () => {});
|
||||
|
||||
it.skip('should call datastore.request', () => {
|
||||
expect(paris.dataStore.request).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call makeApiCall with correct default params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call rawDataToDataSet with correct params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should emit from error$ if encountered an error', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return an Observable', () => {
|
||||
|
||||
});
|
||||
|
||||
xit('should call datastore.request', () => {
|
||||
expect(paris.dataStore.request).to.have.been.called();
|
||||
});
|
||||
|
||||
it('should call Http.request with correct default params', () => {
|
||||
});
|
||||
|
||||
it('should call Http.request with correct params', () => {
|
||||
});
|
||||
it('should call Http.request with correct default params', () => {});
|
||||
|
||||
it('should call Http.request with correct params', () => {});
|
||||
});
|
||||
|
||||
xdescribe('createItem', () => {
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
});
|
||||
it('should call ReadonlyRepository.getModelData with correct params', () => {
|
||||
it('should call ReadonlyRepository.getModelData with correct params', () => {});
|
||||
|
||||
});
|
||||
|
||||
it('should call ReadonlyRepository.getModelData with correct default params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return an Observable', () => {
|
||||
|
||||
});
|
||||
it('should call ReadonlyRepository.getModelData with correct default params', () => {});
|
||||
|
||||
it('should return an Observable', () => {});
|
||||
});
|
||||
|
||||
xdescribe('queryForItem', () => {
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
});
|
||||
it('should call RelationshipRepository.queryForItem with correct params', () => {
|
||||
it('should call RelationshipRepository.queryForItem with correct params', () => {});
|
||||
|
||||
});
|
||||
it('should call RelationshipRepository.queryForItem with correct default params', () => {});
|
||||
|
||||
it('should call RelationshipRepository.queryForItem with correct default params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should throw error if repo doesn\'t exist', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return an Observable', () => {
|
||||
|
||||
});
|
||||
it("should throw error if repo doesn't exist", () => {});
|
||||
|
||||
it('should return an Observable', () => {});
|
||||
});
|
||||
|
||||
xdescribe('getRelatedItem', () => {
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
});
|
||||
it('should call RelationshipRepository.getRelatedItem with correct params', () => {
|
||||
it('should call RelationshipRepository.getRelatedItem with correct params', () => {});
|
||||
|
||||
});
|
||||
it('should call RelationshipRepository.getRelatedItem with correct default params', () => {});
|
||||
|
||||
it('should call RelationshipRepository.getRelatedItem with correct default params', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should throw error if repo doesn\'t exist', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return an Observable', () => {
|
||||
|
||||
});
|
||||
it("should throw error if repo doesn't exist", () => {});
|
||||
|
||||
it('should return an Observable', () => {});
|
||||
});
|
||||
|
||||
xdescribe('getValue', () => {
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
});
|
||||
it('should return null if repo doesn\'t exist', () => {
|
||||
it("should return null if repo doesn't exist", () => {});
|
||||
|
||||
});
|
||||
it("should return null if repo doesn't have defined values", () => {});
|
||||
|
||||
it('should return null if repo doesn\'t have defined values', () => {
|
||||
it("should call valueId if it's a function (predicate)", () => {});
|
||||
|
||||
});
|
||||
|
||||
it('should call valueId if it\'s a function (predicate)', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should call getValueById if valueId is not a function', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return the correct type', () => {
|
||||
|
||||
});
|
||||
it('should call getValueById if valueId is not a function', () => {});
|
||||
|
||||
it('should return the correct type', () => {});
|
||||
});
|
||||
|
||||
xdescribe('getRelationshipRepository', () => {
|
||||
beforeEach(() => {
|
||||
paris = new Paris();
|
||||
});
|
||||
it('should create a RelationshipRepository', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should return a RelationshipRepository', () => {
|
||||
|
||||
});
|
||||
it('should create a RelationshipRepository', () => {});
|
||||
|
||||
it('should return a RelationshipRepository', () => {});
|
||||
});
|
||||
});
|
||||
|
|
33
package.json
33
package.json
|
@ -12,7 +12,8 @@
|
|||
"build": "gulp build",
|
||||
"dev": "rollup -c -w",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "mocha --opts ./test/mocha.opts",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"docs": "typedoc --options typedocconfig.ts"
|
||||
},
|
||||
"author": "Yossi Kolesnicov",
|
||||
|
@ -21,8 +22,6 @@
|
|||
"@compodoc/compodoc": "^1.0.0-beta.7",
|
||||
"@types/async": "^2.0.32",
|
||||
"@types/browser-sync": "^0.0.36",
|
||||
"@types/chai": "^4.1.4",
|
||||
"@types/chai-spies": "^1.0.0",
|
||||
"@types/es6-shim": "^0.31.32",
|
||||
"@types/express": "^4.0.33",
|
||||
"@types/gulp": ">=4.0.0",
|
||||
|
@ -32,27 +31,23 @@
|
|||
"@types/gulp-protractor": "^1.0.30",
|
||||
"@types/gulp-sass": "^0.0.30",
|
||||
"@types/gulp-util": "^3.0.29",
|
||||
"@types/jasmine": "^2.5.52",
|
||||
"@types/jest": "^23.3.1",
|
||||
"@types/lodash-es": "4.17.1",
|
||||
"@types/mocha": "^5.2.4",
|
||||
"@types/node": "^8.0.25",
|
||||
"@types/rimraf": "2.0.2",
|
||||
"@types/run-sequence": "^0.0.29",
|
||||
"@types/systemjs": "^0.20.2",
|
||||
"@types/yargs": "^8.0.2",
|
||||
"chai": "^4.1.2",
|
||||
"chai-spies": "^1.0.0",
|
||||
"core-js": ">=2.4.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-clean": "^0.3.2",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-jasmine": "^2.4.2",
|
||||
"gulp-typescript": "^3.1.3",
|
||||
"husky": "^1.0.0-rc.13",
|
||||
"intl": "^1.2.5",
|
||||
"jest": "^23.5.0",
|
||||
"lodash-es": "4.17.10",
|
||||
"merge2": "^1.0.2",
|
||||
"mocha": "^5.2.0",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rimraf": "~2.5.4",
|
||||
"rollup": "^0.50.0",
|
||||
|
@ -63,6 +58,7 @@
|
|||
"rxjs": "^6.0.0",
|
||||
"standard-version": "^3.0.0",
|
||||
"systemjs": ">=0.20.12",
|
||||
"ts-jest": "^23.1.3",
|
||||
"ts-node": "^7.0.0",
|
||||
"typedoc": "^0.11.1",
|
||||
"typescript": "^2.7.2",
|
||||
|
@ -72,5 +68,24 @@
|
|||
"rxjs": ">=6.0.0",
|
||||
"lodash-es": "4.5.0"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.(js|ts)$": "ts-jest"
|
||||
},
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/"
|
||||
],
|
||||
"setupTestFrameworkScriptFile": "<rootDir>/jest-setup.ts",
|
||||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|js)$",
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"js",
|
||||
"json",
|
||||
"node"
|
||||
],
|
||||
"transformIgnorePatterns": [
|
||||
"<rootDir>/node_modules/(?!lodash-es)"
|
||||
]
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
const config = {
|
||||
baseUrl: 'http://localhost:5555/',
|
||||
|
||||
specs: [
|
||||
'./dist/e2e/**/*.e2e-spec.js'
|
||||
],
|
||||
|
||||
exclude: [],
|
||||
|
||||
// 'jasmine' by default will use the latest jasmine framework
|
||||
framework: 'jasmine',
|
||||
|
||||
// allScriptsTimeout: 110000,
|
||||
|
||||
jasmineNodeOpts: {
|
||||
// showTiming: true,
|
||||
showColors: true,
|
||||
isVerbose: false,
|
||||
includeStackTrace: false,
|
||||
// defaultTimeoutInterval: 400000
|
||||
},
|
||||
|
||||
directConnect: true,
|
||||
|
||||
capabilities: {
|
||||
browserName: 'chrome'
|
||||
},
|
||||
|
||||
onPrepare: function() {
|
||||
browser.ignoreSynchronization = false;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Angular 2 configuration
|
||||
*
|
||||
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
|
||||
* `rootEl`
|
||||
*/
|
||||
useAllAngular2AppRoots: true
|
||||
};
|
||||
|
||||
if (process.env.TRAVIS) {
|
||||
config.capabilities = {
|
||||
browserName: 'firefox'
|
||||
};
|
||||
}
|
||||
|
||||
exports.config = config;
|
|
@ -1,16 +0,0 @@
|
|||
// Load our SystemJS configuration.
|
||||
System.config({
|
||||
baseURL: '/base/',
|
||||
paths: {
|
||||
rxjs: 'node_modules/rxjs',
|
||||
},
|
||||
packages: {
|
||||
'': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
rxjs: {
|
||||
defaultExtension: 'js'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
68
test-main.js
68
test-main.js
|
@ -1,68 +0,0 @@
|
|||
if (!Object.hasOwnProperty('name')) {
|
||||
Object.defineProperty(Function.prototype, 'name', {
|
||||
get: function () {
|
||||
var matches = this.toString().match(/^\s*function\s*(\S*)\s*\(/);
|
||||
var name = matches && matches.length > 1 ? matches[1] : "";
|
||||
Object.defineProperty(this, 'name', { value: name });
|
||||
return name;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Turn on full stack traces in errors to help debugging
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
|
||||
|
||||
// Cancel Karma's synchronous start,
|
||||
// we will call `__karma__.start()` later, once all the specs are loaded.
|
||||
__karma__.loaded = function () { };
|
||||
|
||||
Promise.all([
|
||||
System.import('node_modules/@angular/core/bundles/core-testing.umd.js'),
|
||||
System.import('node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js')
|
||||
]).then(function (providers) {
|
||||
var testing = providers[0];
|
||||
var testingBrowser = providers[1];
|
||||
|
||||
testing.TestBed.initTestEnvironment(
|
||||
testingBrowser.BrowserDynamicTestingModule,
|
||||
testingBrowser.platformBrowserDynamicTesting()
|
||||
);
|
||||
}).then(function () {
|
||||
return Promise.all(
|
||||
Object.keys(window.__karma__.files) // All files served by Karma.
|
||||
.filter(onlySpecFiles)
|
||||
.map(file2moduleName)
|
||||
.map(function (path) {
|
||||
return System.import(path).then(function (module) {
|
||||
if (module.hasOwnProperty('main')) {
|
||||
module.main();
|
||||
} else {
|
||||
throw new Error('Module ' + path + ' does not implement main() method.');
|
||||
}
|
||||
});
|
||||
}));
|
||||
})
|
||||
.then(function () {
|
||||
__karma__.start();
|
||||
}, function (error) {
|
||||
console.error(error.stack || error);
|
||||
__karma__.start();
|
||||
});
|
||||
|
||||
function onlySpecFiles(path) {
|
||||
// check for individual files, if not given, always matches to all
|
||||
var patternMatched = __karma__.config.files ?
|
||||
path.match(new RegExp(__karma__.config.files)) : true;
|
||||
|
||||
return patternMatched && /[\.|_]spec\.js$/.test(path);
|
||||
}
|
||||
|
||||
// Normalize paths to module names.
|
||||
function file2moduleName(filePath) {
|
||||
return filePath.replace(/\\/g, '/')
|
||||
.replace(/^\/base\//, '')
|
||||
.replace(/\.js$/, '');
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
--ui mocha-typescript
|
||||
lib/**/*.spec.ts
|
|
@ -9,23 +9,16 @@
|
|||
"outDir": "./bundle",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowJs": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitUseStrict": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types",
|
||||
"node_modules"
|
||||
],
|
||||
"types" : ["node", "lodash-es"],
|
||||
"typeRoots": ["node_modules/@types", "node_modules"],
|
||||
"types": ["node", "lodash-es", "jest"],
|
||||
"baseUrl": "/",
|
||||
"paths": {
|
||||
"@angular/*": [
|
||||
"../node_modules/@angular/*"
|
||||
],
|
||||
"rxjs/*": [
|
||||
"../node_modules/rxjs/*"
|
||||
]
|
||||
"rxjs/*": ["../node_modules/rxjs/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,10 @@
|
|||
"noImplicitReturns": true,
|
||||
"noImplicitUseStrict": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types",
|
||||
"node_modules"
|
||||
],
|
||||
"types" : ["node", "lodash-es"],
|
||||
"typeRoots": ["node_modules/@types", "node_modules"],
|
||||
"types": ["node", "lodash-es"],
|
||||
"baseUrl": "/"
|
||||
},
|
||||
"include": [
|
||||
"index.ts",
|
||||
"lib/**/*"
|
||||
]
|
||||
"include": ["index.ts", "lib/**/*"],
|
||||
"exclude": ["lib/**/*.spec.ts"]
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче