-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangpei07
committed
Apr 3, 2018
1 parent
8b36445
commit d4bd819
Showing
6 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,5 @@ | ||
# utils | ||
|
||
> 2018-03-31 | ||
- 文档:https://searchfe.github.io/utils/ |
This file contains 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,87 @@ | ||
// Karma configuration | ||
// Generated on Wed Apr 04 2018 00:03:37 GMT+0800 (CST) | ||
|
||
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: ['mocha', 'requirejs', 'chai-as-promised', 'chai-sinon'], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'test-main.js', | ||
{pattern: 'src/**/*.js', included: false}, | ||
{pattern: 'amd_modules/**/*.js', included: false}, | ||
{pattern: 'test/**/*.js', included: false} | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
'**/*.swp' | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
// source files, that you wanna generate coverage for | ||
// do not include tests or libraries | ||
// (these files will be instrumented by Istanbul) | ||
'src/**/*.js': ['coverage'] | ||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['mocha'], | ||
coverageReporter: { | ||
reporters: [ | ||
{ | ||
type: 'text-summary' | ||
}, { | ||
type: 'lcov', | ||
dir: 'coverage/' | ||
} | ||
] | ||
}, | ||
|
||
|
||
// 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: ['ChromeHeadless'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true, | ||
|
||
// Concurrency level | ||
// how many browser should be started simultaneous | ||
concurrency: Infinity | ||
}) | ||
} |
This file contains 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 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,16 @@ | ||
define(function() { | ||
|
||
function Browser () { | ||
this._name = ''; | ||
}; | ||
|
||
Browser.prototype._getBrowserName = function (ua) { | ||
var ua = ua || navigator.userAgent; | ||
if (ua.indexOf('QQBrowser') > -1) { | ||
this._name = 'qq'; | ||
} | ||
} | ||
|
||
return Browser; | ||
|
||
}); |
This file contains 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,33 @@ | ||
/** | ||
* @file testMain test entry for karma | ||
* @author harttle<[email protected]> | ||
*/ | ||
var allTestFiles = []; | ||
var TEST_REGEXP = /test\/.*\.js$/i; | ||
|
||
// Get a list of all the test files to include | ||
Object.keys(window.__karma__.files).forEach(function (file) { | ||
if (TEST_REGEXP.test(file)) { | ||
// Normalize paths to RequireJS module names. | ||
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension) | ||
// then do not normalize the paths | ||
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, ''); | ||
allTestFiles.push(normalizedTestModule); | ||
} | ||
}); | ||
|
||
require.config({ | ||
// Karma serves files under /base, which is the basePath from your config file | ||
baseUrl: '/base', | ||
|
||
// dynamically load all test files | ||
deps: allTestFiles, | ||
|
||
// external AMD modules | ||
paths: { | ||
'@searchfe/assert': 'amd_modules/@searchfe/assert' | ||
}, | ||
|
||
// we have to kickoff jasmine, as it is asynchronous | ||
callback: window.__karma__.start | ||
}); |
This file contains 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,12 @@ | ||
define(['src/index'], function (Browser) { | ||
describe('Browser', function () { | ||
describe('new', function () { | ||
it('should get qq browser name', function () { | ||
var ua = 'Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; HUAWEI C8818 Build/HuaweiC8818) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.8 Mobile Safari/537.36'; | ||
var browser = new Browser(); | ||
browser._getBrowserName(ua); | ||
expect(browser._name).to.equal('qq'); | ||
}); | ||
}); | ||
}); | ||
}); |