Last active
July 5, 2018 12:34
-
-
Save OliverLeitner/324bdf5d8b7c252bd095c5cfc4be01f7 to your computer and use it in GitHub Desktop.
simple jasmine sample
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
/** | |
* super sexy class | |
*/ | |
//a class... basically a big funct | |
class Testing { | |
//adding some consts | |
constructor() { | |
this.num1 = 10; | |
this.num2 = 100; | |
this.string = 'hello'; | |
} | |
//some hello world funct | |
hello(string) { | |
return this.string + ' ' + string; | |
} | |
//some sexy calc funct | |
sexyCalc(num1, num2) { | |
return (num1 * this.num1) + ' is not ' + (num2 * this.num2); | |
} | |
} |
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
describe('Testing', function(){ | |
//run before each test | |
beforeEach(function() { | |
tt = new Testing(); | |
}); | |
//testing the first function of the class | |
describe('tt.hello', function(){ | |
it('should say hello world', function(){ | |
expect(tt.hello('world')).toEqual('hello world'); | |
}); | |
}); | |
//first static multiplier | |
describe('tt.num1', function(){ | |
it('should be 10', function(){ | |
expect(tt.num1).toEqual(10); | |
}); | |
}); | |
//second static multiplier | |
describe('tt.num2', function(){ | |
it('should be 100', function(){ | |
expect(tt.num2).toEqual(100); | |
}); | |
}); | |
//testing the second function of the class | |
describe('tt.sexyCalc', function(){ | |
it('should multiply stuff', function(){ | |
let fakenum1 = 4; | |
let fakenum2 = 8; | |
expect(tt.sexyCalc(fakenum1, fakenum2)).toEqual(40 + ' is not ' + 800); | |
}); | |
}); | |
}); |
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
//just some starter comment | |
class Testing { | |
//class wide constants | |
protected num1 : number = 10; | |
protected num2 : number = 100; | |
protected myString : string = 'hello'; | |
//every class -> constructor | |
construct(){ } | |
//basic string back | |
public hello = ((a_string: string) : string => { | |
return this.myString + ' ' + a_string; | |
}); | |
//basic math stuff | |
public sexyCalc = ((num1 : number, num2 : number) : any => { | |
return (num1 * this.num1) + ' is not ' + (num2 * this.num2); | |
}); | |
} |
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
// Karma configuration | |
// Generated on Thu Jul 05 2018 13:40:05 GMT+0200 (GMT+02:00) | |
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: ['jasmine'], | |
// list of files / patterns to load in the browser | |
files: [ | |
'functs.js', | |
'functs.specs.js' | |
], | |
// list of files / patterns to exclude | |
exclude: [ | |
], | |
// preprocess matching files before serving them to the browser | |
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | |
preprocessors: { | |
}, | |
// 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_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: ['Chrome'], | |
// Continuous Integration mode | |
// if true, Karma captures browsers, runs the tests and exits | |
singleRun: false, | |
// 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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Jasmine Spec Runner v3.0.x</title> | |
<link rel="shortcut icon" type="image/png" href="/node_modules/jasmine-core/images/jasmine_favicon.png"> | |
<link rel="stylesheet" type="text/css" href="/node_modules/jasmine-core/lib/jasmine-core/jasmine.css"> | |
<script type="text/javascript" src="/node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script> | |
<script type="text/javascript" src="/node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> | |
<script type="text/javascript" src="/node_modules/jasmine-core/lib/jasmine-core/boot.js"></script> | |
<!-- include source files here... --> | |
<script type="text/javascript" src="functs.js"></script> | |
<!-- include spec files here... --> | |
<script type="text/javascript" src="functs.specs.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment