Skip to content

Commit

Permalink
Add Karma again >.>
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Sep 6, 2017
1 parent 1b5e7a2 commit 1590f4b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.swp
node_modules
!tests/*
!karma.conf.js
49 changes: 49 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = function(config) {
const configuration = {
basePath: '',
frameworks: ['mocha', 'chai', 'karma-typescript'],
files: [
{
pattern: 'rpc.ts',
included: false,
},
{
pattern: 'tests/*.test.js',
included: false,
},
'tests/tests.js',
],
preprocessors: {
'rpc.ts': ['karma-typescript'],
},
karmaTypescriptConfig: {
tsconfig: './tsconfig.json',
coverageOptions: {
instrumentation: false,
},
},
reporters: ['progress', 'karma-typescript'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
singleRun: true,
concurrency: Infinity,
browsers: ['ChromeCanary', 'Safari'],
customLaunchers: {
ChromeCanaryHarmony: {
base: 'ChromeCanary',
flags: ['--js-flags=--harmony'],
},
DockerChrome: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
},
};

if (process.env.INSIDE_DOCKER)
configuration.browsers = ['DockerChrome'];

config.set(configuration);
};
10 changes: 4 additions & 6 deletions rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface InvocationRequest {
id?: string;
type: InvocationType;
callPath: PropertyKey[];
argumentsList?: any[];
argumentsList?: Iterable<any>;
}

type InvocationType = 'CONSTRUCT' | 'GET' | 'APPLY';
Expand Down Expand Up @@ -98,12 +98,10 @@ function batchingProxy(cb: BatchingProxyCallback): Proxy {
apply(_target, _thisArg, argumentsList) {
// We use `bind` as an indicator to have a remote function bound locally.
// The actual target for `bind()` is currently ignored.
if(callPath[callPath.length - 1] === 'bind') {
if (callPath[callPath.length - 1] === 'bind') {
const localCallPath = callPath.slice();
callPath = [];
return (...args: any[]) => {
return cb('APPLY', localCallPath.slice(0, -1), args);
}
return (...args: any[]) => cb('APPLY', localCallPath.slice(0, -1), args);
}
const r = cb('APPLY', callPath, argumentsList);
callPath = [];
Expand Down Expand Up @@ -222,7 +220,7 @@ function makeInvocationResult(obj: any): InvocationResult {
}

export function invoker(rootObj: any, endpoint: Endpoint) {
if(endpoint instanceof MessagePort)
if (endpoint instanceof MessagePort)
endpoint.start();
endpoint.addEventListener('message', async function(event: MessageEvent) {
const irequest = event.data as InvocationRequest;
Expand Down

0 comments on commit 1590f4b

Please sign in to comment.