|
|
@ -1,8 +1,8 @@ |
|
|
|
import { RemixResolve, ImportResolver, RemixResolveApi } from '../src' |
|
|
|
import { RemixResolve, RemixResolveApi } from '../src' |
|
|
|
import * as fs from 'fs' |
|
|
|
import * as fs from 'fs' |
|
|
|
import * as path from 'path' |
|
|
|
import * as path from 'path' |
|
|
|
import * as assert from 'assert' |
|
|
|
import * as assert from 'assert' |
|
|
|
import { Plugin, AppManager, PluginProfile } from 'remix-plugin' |
|
|
|
import { AppManager, PluginProfile } from 'remix-plugin' |
|
|
|
|
|
|
|
|
|
|
|
const RemixResolveProfile: PluginProfile<RemixResolve> = { |
|
|
|
const RemixResolveProfile: PluginProfile<RemixResolve> = { |
|
|
|
type: 'remix-resolve', |
|
|
|
type: 'remix-resolve', |
|
|
@ -19,11 +19,19 @@ interface IAppManager { |
|
|
|
describe('testRunner', () => { |
|
|
|
describe('testRunner', () => { |
|
|
|
describe('#resolve', () => { |
|
|
|
describe('#resolve', () => { |
|
|
|
describe('test example_1 [local imports]]', () => { |
|
|
|
describe('test example_1 [local imports]]', () => { |
|
|
|
|
|
|
|
// AppManager tests
|
|
|
|
|
|
|
|
describe('test with AppManager', () => { |
|
|
|
|
|
|
|
let app: AppManager<IAppManager> |
|
|
|
|
|
|
|
let api: RemixResolveApi |
|
|
|
|
|
|
|
|
|
|
|
const fileName = '../remix-resolve/tests/example_1/greeter.sol' |
|
|
|
const fileName = '../remix-resolve/tests/example_1/greeter.sol' |
|
|
|
let results = {} |
|
|
|
let results: object = {} |
|
|
|
|
|
|
|
|
|
|
|
before(done => { |
|
|
|
before(done => { |
|
|
|
let resolver: ImportResolver = new ImportResolver() |
|
|
|
api = new RemixResolveApi() |
|
|
|
|
|
|
|
app = new AppManager({ |
|
|
|
|
|
|
|
modules: [{ json: RemixResolveProfile, api }] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
function handleLocal(pathString: string, filePath: string) { |
|
|
|
function handleLocal(pathString: string, filePath: string) { |
|
|
|
// if no relative/absolute path given then search in node_modules folder
|
|
|
|
// if no relative/absolute path given then search in node_modules folder
|
|
|
@ -44,7 +52,8 @@ describe('testRunner', () => { |
|
|
|
handle: (match: Array<string>) => { return handleLocal(match[2], match[3]) } |
|
|
|
handle: (match: Array<string>) => { return handleLocal(match[2], match[3]) } |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
resolver.resolve(fileName, localFSHandler) |
|
|
|
//app.calls[api.type].resolve(fileName, localFSHandler)
|
|
|
|
|
|
|
|
api.resolve(fileName, localFSHandler) |
|
|
|
.then(sources => { |
|
|
|
.then(sources => { |
|
|
|
results = sources |
|
|
|
results = sources |
|
|
|
done() |
|
|
|
done() |
|
|
@ -53,9 +62,8 @@ describe('testRunner', () => { |
|
|
|
throw e |
|
|
|
throw e |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
it('Plugin should be added to app', () => { |
|
|
|
it('should have 3 items', () => { |
|
|
|
assert.equal(typeof(app.calls[api.type].resolve), 'function') |
|
|
|
assert.equal(Object.keys(results).length, 3) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('should returns contract content of given local path', () => { |
|
|
|
it('should returns contract content of given local path', () => { |
|
|
@ -66,23 +74,6 @@ describe('testRunner', () => { |
|
|
|
} |
|
|
|
} |
|
|
|
assert.deepEqual(results, expt) |
|
|
|
assert.deepEqual(results, expt) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// test IPFShandle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AppManager tests
|
|
|
|
|
|
|
|
describe('test with AppManager', () => { |
|
|
|
|
|
|
|
let app: AppManager<IAppManager> |
|
|
|
|
|
|
|
let api: RemixResolveApi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before(() => { |
|
|
|
|
|
|
|
api = new RemixResolveApi() |
|
|
|
|
|
|
|
app = new AppManager({ |
|
|
|
|
|
|
|
modules: [{ json: RemixResolveProfile, api }] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
it('Plugin should be added to app', () => { |
|
|
|
|
|
|
|
assert.equal(typeof(app.calls[api.type].resolve), 'function') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|