This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Run core tests in the browser #55
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
|
||
// base path, that will be used to resolve files and exclude | ||
basePath: '', | ||
|
||
// frameworks to use | ||
frameworks: ['mocha'], | ||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'tests/test-core/browser.js' | ||
], | ||
|
||
// list of preprocessors | ||
preprocessors: { | ||
'tests/test-core/*': ['webpack'] | ||
}, | ||
|
||
webpack: { | ||
resolve: { | ||
extensions: ['', '.js'] | ||
}, | ||
externals: { | ||
fs: '{}' | ||
}, | ||
node: { | ||
Buffer: true | ||
} | ||
}, | ||
|
||
webpackMiddleware: { | ||
noInfo: true, | ||
stats: { | ||
colors: true | ||
} | ||
}, | ||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' | ||
reporters: ['spec'], | ||
|
||
// 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: false, | ||
|
||
// Start these browsers, currently available: | ||
// - Chrome | ||
// - ChromeCanary | ||
// - Firefox | ||
// - Opera (has to be installed with `npm install karma-opera-launcher`) | ||
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) | ||
// - PhantomJS | ||
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) | ||
browsers: process.env.TRAVIS ? ['Firefox'] : ['Chrome'], | ||
|
||
// If browser does not capture in given timeout [ms], kill it | ||
captureTimeout: 60000, | ||
|
||
// Continuous Integration mode | ||
// if true, it capture browsers, run tests and exit | ||
singleRun: true | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const localStorage = require('local-storage-blob-store') | ||
const IPFSRepo = require('ipfs-repo') | ||
|
||
const options = { | ||
stores: { | ||
keys: localStorage, | ||
config: localStorage, | ||
datastore: localStorage, | ||
// datastoreLegacy: needs https://github.com/ipfs/js-ipfs-repo/issues/6#issuecomment-164650642 | ||
logs: localStorage, | ||
locks: localStorage, | ||
version: localStorage | ||
} | ||
} | ||
|
||
module.exports = () => { | ||
return new IPFSRepo('ipfs', options) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const isNode = !global.window | ||
|
||
module.exports = isNode | ||
? require('./node') | ||
: require('./browser') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const os = require('os') | ||
const fs = require('fs-blob-store') | ||
const IPFSRepo = require('ipfs-repo') | ||
|
||
const options = { | ||
stores: { | ||
keys: fs, | ||
config: fs, | ||
datastore: fs, | ||
// datastoreLegacy: needs https://github.com/ipfs/js-ipfs-repo/issues/6#issuecomment-164650642 | ||
logs: fs, | ||
locks: fs, | ||
version: fs | ||
} | ||
} | ||
|
||
module.exports = () => { | ||
const repoPath = process.env.IPFS_PATH || os.homedir() + '/.ipfs' | ||
return new IPFSRepo(repoPath, options) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* globals describe, before */ | ||
|
||
// const expect = require('chai').expect | ||
const async = require('async') | ||
const store = require('local-storage-blob-store') | ||
const _ = require('lodash') | ||
|
||
var repoContext = require.context('raw!../repo-example', true) | ||
|
||
describe('core', function () { | ||
before(function (done) { | ||
window.localStorage.clear() | ||
|
||
var repoData = [] | ||
repoContext.keys().forEach(function (key) { | ||
repoData.push({ | ||
key: key.replace('./', ''), | ||
value: repoContext(key) | ||
}) | ||
}) | ||
|
||
var mainBlob = store('ipfs') | ||
var blocksBlob = store('ipfs/') | ||
|
||
async.eachSeries(repoData, (file, cb) => { | ||
if (_.startsWith(file.key, 'datastore/')) { | ||
return cb() | ||
} | ||
|
||
const blob = _.startsWith(file.key, 'blocks/') | ||
? blocksBlob | ||
: mainBlob | ||
|
||
blob.createWriteStream({ | ||
key: file.key | ||
}).end(file.value, cb) | ||
}, done) | ||
}) | ||
|
||
const testsContext = require.context('.', true, /test-*/) | ||
testsContext | ||
.keys() | ||
.forEach(key => testsContext(key)) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one!