Last active
August 24, 2023 19:23
-
-
Save robinboehm/8978574 to your computer and use it in GitHub Desktop.
task scopes
This file contains hidden or 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> | |
<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="task.js"></script> | |
<!-- Spec --> | |
<script src="spec.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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("A variable something", function () { | |
it("should be defined", function () { | |
expect(something).toBeDefined(); | |
}); | |
}); | |
describe("A variable innerResult", function () { | |
it("should be defined", function () { | |
expect(innerResult).toBeDefined(); | |
}); | |
}); | |
describe("A variable outerResult", function () { | |
it("should be defined", function () { | |
expect(outerResult).toBeDefined(); | |
}); | |
}); | |
describe("A variable result_innerResult", function () { | |
it("should be defined", function () { | |
expect(result_innerResult).toBeDefined(); | |
}); | |
it("should contain the correct value", function () { | |
expect(result_innerResult).toBe(something); | |
}); | |
}); | |
describe("A variable result_outerResult", function () { | |
it("should be defined", function () { | |
expect(result_outerResult).toBeDefined(); | |
}); | |
it("should contain the correct value", function () { | |
expect(result_outerResult).toBe(something); | |
}); | |
}); | |
describe("A variable named variable", function () { | |
it("should be defined", function () { | |
expect(variable).toBeDefined(); | |
}); | |
it("should contain the string 'top-level'", function () { | |
expect(variable).toBe("top-level"); | |
}); | |
}); | |
describe("A variable parentFunction", function () { | |
it("should be defined", function () { | |
expect(parentFunction).toBeDefined(); | |
}); | |
it("should be a function", function () { | |
expect(typeof parentFunction).toBe('function'); | |
}); | |
it("should define a local variable named variable with string 'local'", function () { | |
expect(parentFunction.toString()).toMatch(/var variable = ['"]local['"];/); | |
}); | |
it("should return a function", function () { | |
expect(typeof parentFunction()).toBe('function'); | |
}); | |
it("should return a function that return the locale variable", function () { | |
expect(parentFunction().toString()).toMatch(/return variable;/); | |
}); | |
it("should returned function should return the locale variable", function () { | |
expect(parentFunction()()).toBe('local'); | |
}); | |
}); | |
describe("A variable childFn", function () { | |
it("should be defined", function () { | |
expect(childFn).toBeDefined(); | |
}); | |
it("should contain the result of parentFunction()", function () { | |
expect(childFn.toString()).toEqual(parentFunction().toString()); | |
}); | |
}); | |
describe("A variable localeVariable", function () { | |
it("should be defined", function () { | |
expect(localeVariable).toBeDefined(); | |
}); | |
it("should contain the result of childFn() --> 'locale'", function () { | |
expect(localeVariable).toEqual('local'); | |
}); | |
}); | |
This file contains hidden or 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
var something = 1; | |
if (true) { | |
var something = 2; | |
var innerResult = something; | |
} | |
var outerResult = something; | |
var result_innerResult; | |
var result_outerResult; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment