Преглед на файлове

Add karma and jasmine unit testing to lib-jitsi-meet. also add a very basic example test for SDPUtil

dev1
brian baldino преди 8 години
родител
ревизия
aa1bda86a6
променени са 6 файла, в които са добавени 95 реда и са изтрити 4 реда
  1. 2
    1
      .eslintrc.js
  2. 2
    0
      .jshintignore
  3. 2
    1
      .jshintrc
  4. 70
    0
      karma.conf.js
  5. 11
    0
      modules/xmpp/SDPUtil.spec.js
  6. 8
    2
      package.json

+ 2
- 1
.eslintrc.js Целия файл

@@ -2,7 +2,8 @@ module.exports = {
2 2
     'env': {
3 3
         'browser': true,
4 4
         'commonjs': true,
5
-        'es6': true
5
+        'es6': true,
6
+        'jasmine': true
6 7
     },
7 8
     'extends': 'eslint:recommended',
8 9
     'globals': {

+ 2
- 0
.jshintignore Целия файл

@@ -3,6 +3,7 @@ libs
3 3
 lib-jitsi-meet.js
4 4
 lib-jitsi-meet.min.js
5 5
 lib-jitsi-meet.js.map
6
+karma.conf.js
6 7
 doc
7 8
 
8 9
 
@@ -30,3 +31,4 @@ JitsiParticipant.js
30 31
 JitsiMeetJS.js
31 32
 JitsiConnection.js
32 33
 JitsiConference.js
34
+modules/xmpp/SampleSdpStrings.js

+ 2
- 1
.jshintrc Целия файл

@@ -15,5 +15,6 @@
15 15
     "node": true, // Node.js
16 16
     "trailing": true,
17 17
     "undef": true, // true: Require all non-global variables to be declared (prevents global leaks)
18
-    "white": true
18
+    "white": true,
19
+    "jasmine": true
19 20
 }

+ 70
- 0
karma.conf.js Целия файл

@@ -0,0 +1,70 @@
1
+// Karma configuration
2
+// Generated on Wed Dec 07 2016 14:40:28 GMT-0800 (PST)
3
+
4
+module.exports = function(config) {
5
+  config.set({
6
+
7
+    // base path that will be used to resolve all patterns (eg. files, exclude)
8
+    basePath: '',
9
+
10
+
11
+    // frameworks to use
12
+    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13
+    frameworks: ['jasmine'],
14
+
15
+
16
+    // list of files / patterns to load in the browser
17
+    files: [
18
+        './JitsiMeetJS.js',
19
+        './modules/**/*.spec.js',
20
+    ],
21
+
22
+
23
+    // list of files to exclude
24
+    exclude: [
25
+    ],
26
+
27
+
28
+    // preprocess matching files before serving them to the browser
29
+    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
30
+    preprocessors: {
31
+        './JitsiMeetJS.js': ['webpack'],
32
+        './**/*.spec.js': ['webpack']
33
+    },
34
+
35
+
36
+    // test results reporter to use
37
+    // possible values: 'dots', 'progress'
38
+    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
39
+    reporters: ['progress'],
40
+
41
+
42
+    // web server port
43
+    port: 9876,
44
+
45
+
46
+    // enable / disable colors in the output (reporters and logs)
47
+    colors: true,
48
+
49
+
50
+    // level of logging
51
+    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
52
+    logLevel: config.LOG_INFO,
53
+
54
+
55
+    // enable / disable watching file and executing tests whenever any file changes
56
+    autoWatch: false,
57
+
58
+
59
+    // start these browsers
60
+    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
61
+    browsers: ['Chrome'],
62
+
63
+
64
+    // Continuous Integration mode
65
+    // if true, Karma captures browsers, runs the tests and exits
66
+    singleRun: false,
67
+
68
+	webpack: require("./webpack.config.js"),
69
+  });
70
+};

+ 11
- 0
modules/xmpp/SDPUtil.spec.js Целия файл

@@ -0,0 +1,11 @@
1
+var SDPUtil = require("./SDPUtil.js");
2
+
3
+describe("SDPUtil", function() {
4
+
5
+    it("should parse an ice ufrag correctly", function() {
6
+        let line = "a=ice-ufrag:3jlcc1b3j1rqt6";
7
+        let parsed = SDPUtil.parse_iceufrag(line);
8
+
9
+        expect(parsed).toEqual("3jlcc1b3j1rqt6");
10
+    });
11
+});

+ 8
- 2
package.json Целия файл

@@ -38,12 +38,18 @@
38 38
     "jshint": "^2.8.0",
39 39
     "precommit-hook": "^3.0.0",
40 40
     "string-replace-loader": "*",
41
-    "webpack": "*"
41
+    "webpack": "*",
42
+    "jasmine-core": "^2.2.0",
43
+    "karma": "^0.13.2",
44
+    "karma-chrome-launcher": "^0.2.0",
45
+    "karma-jasmine": "^0.3.6",
46
+    "karma-webpack": "^1.6.0"
42 47
   },
43 48
   "scripts": {
44 49
     "install": "webpack -p",
45 50
     "lint": "jshint . && eslint .",
46
-    "validate": "npm ls"
51
+    "validate": "npm ls",
52
+    "test": "./node_modules/karma/bin/karma start karma.conf.js"
47 53
   },
48 54
   "pre-commit": [
49 55
     "lint"

Loading…
Отказ
Запис