From 7363f0c311dcd61b7a977f2a4c9e6df5a016705e Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 5 Jan 2021 14:19:24 +0530 Subject: [PATCH] tests for specific blob github import --- libs/remix-url-resolver/tests/test.ts | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libs/remix-url-resolver/tests/test.ts b/libs/remix-url-resolver/tests/test.ts index b64a84ffbb..ca4ba0e7a5 100644 --- a/libs/remix-url-resolver/tests/test.ts +++ b/libs/remix-url-resolver/tests/test.ts @@ -85,6 +85,37 @@ describe('testRunner', () => { assert.deepEqual(results, expt) }) }) + + // Test github import for specific blob + describe('test getting github imports for specific blob', () => { + const urlResolver = new RemixURLResolver() + const fileName: string = 'https://github.com/ethereum/remix-project/blob/v0.10.7/libs/remix-url-resolver/tests/example_1/greeter.sol' + let results: object = {} + + before(done => { + urlResolver.resolve(fileName) + .then((sources: object) => { + results = sources + done() + }) + .catch((e: Error) => { + throw e + }) + }) + + it('should have 3 items', () => { + assert.equal(Object.keys(results).length, 3) + }) + it('should return contract content of given github path', () => { + const expt: object = { + cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', + content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}) + '\n', + type: 'github' + } + assert.deepEqual(results, expt) + }) + }) + // Test https imports describe('test getting https imports', () => { const urlResolver = new RemixURLResolver()