Skip to content

Instantly share code, notes, and snippets.

@robinboehm
Last active September 14, 2015 10:40
Show Gist options
  • Save robinboehm/8976378 to your computer and use it in GitHub Desktop.
Save robinboehm/8976378 to your computer and use it in GitHub Desktop.
task functions
describe("A simpleFunction variable", function () {
it("should be defined", function () {
expect(simpleFunction).toBeDefined();
});
it("should be a function", function () {
expect(typeof simpleFunction).toBe('function');
});
it("should return undefined", function () {
expect(simpleFunction()).toBeUndefined();
});
});
describe("A argumentFunction variable", function () {
it("should be defined", function () {
expect(argumentFunction).toBeDefined();
});
it("should be a function", function () {
expect(typeof argumentFunction).toBe('function');
});
it("should accept an argument", function () {
expect(argumentFunction.toString()).toMatch(/function \(.\w*\)\w*/);
});
it("should multiply the argument with 10 and return it", function () {
expect(argumentFunction(100)).toBe(100*10);
});
it("should contain a property named multiply", function () {
expect(argumentFunction.multiply).toBeDefined();
});
it("should use the property multiply to calculate the result", function () {
expect(argumentFunction.toString()).toMatch(/argumentFunction\.multiply/);
});
it("should check if the input is defined. If not, set 10 as default ( Arguments are optional )", function () {
expect(argumentFunction()).toBe(100);
});
});
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="bower_components/jasmine/lib/jasmine-core/jasmine.css">
<link rel="stylesheet" type="text/css" href="css/jasmine.css">
</head>
<body>
<script src="bower_components/jasmine/lib/jasmine-core/jasmine.js"></script>
<script src="bower_components/jasmine/lib/jasmine-core/jasmine-html.js"></script>
<script src="bower_components/jasmine/lib/jasmine-core/boot.js"></script>
<!-- App -->
<script src="functions.js"></script>
<!-- Spec -->
<script src="functions.spec.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment