diff --git a/conf/karma.conf.js b/conf/karma.conf.js new file mode 100644 index 000000000..2e62e6b49 --- /dev/null +++ b/conf/karma.conf.js @@ -0,0 +1,66 @@ +// Karma configuration +// Generated on Mon Nov 03 2014 07:53:38 GMT+0100 (CET) + +module.exports = function (config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + browserify: { + watch: true + }, + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'vendor/requirejs/require.js', + 'vendor/jasmine/lib/jasmine-core/jasmine.js', + 'src/**/*.spec.js', + 'test/test-main.js' + ], + + + // list of files to exclude + exclude: [], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // 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_DEBUG, + + + // 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: ['Chrome'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; diff --git a/src/parser/mermaid.spec.js b/src/parser/mermaid.spec.js new file mode 100644 index 000000000..dc4ed8c58 --- /dev/null +++ b/src/parser/mermaid.spec.js @@ -0,0 +1,28 @@ +/** + * Created by knut on 14-11-03. + */ +define('parser/mermaid.spec',['parser/scope','parser/mermaid.js'],function(scope, p){ + console.log('here:'+p); + + describe('when parsing ',function(){ + beforeEach(function(){ + console.log('here'); + p.yy = scope; + }); + it('should',function(){ + var res = p.parse('A-->B;'); + + expect(p.yy.getLinks()).toBe('apa'); + }) + }); + + + describe('just checking', function() { + + it('works for app', function () { + expect(2).toBe(2); + }); + }); + +}); + diff --git a/src/parser/scope.js b/src/parser/scope.js new file mode 100644 index 000000000..847390132 --- /dev/null +++ b/src/parser/scope.js @@ -0,0 +1,18 @@ +/** + * Created by knut on 14-11-03. + */ +define('parser/scope',function() { + var scope = { + addVertex: function (id, text, type, style) { + console.log('Got node ' + id + ' ' + type + ' ' + text + ' styles: ' + JSON.stringify(style)); + }, + addLink: function (start, end, type, linktext) { + console.log('Got link from ' + start + ' to ' + end + ' type:' + type.type + ' linktext:' + linktext); + }, + getLinks: function () { + return 'apa'; + } + }; + + return scope; +}); diff --git a/test/test-main.js b/test/test-main.js new file mode 100644 index 000000000..a67981c28 --- /dev/null +++ b/test/test-main.js @@ -0,0 +1,24 @@ +/** + * Created by knut on 14-11-03. + */ +var tests = []; +for (var file in window.__karma__.files) { + if (window.__karma__.files.hasOwnProperty(file)) { + if (/spec\.js$/.test(file)) { + var file2 = file.substr(10,file.length-13); + console.log(file2); + tests.push(file2); + } + } +} + +require.config({ + // Karma serves files from '/base' + baseUrl: '/base/src', + + // ask Require.js to load these files (all our tests) + deps: tests, + + // start test run, once Require.js is done + callback: window.__karma__.start +});