Skip to content

Commit

Permalink
Integrated Jasmine as a test suite and setup some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p0wen committed Sep 28, 2020
1 parent a576cca commit eba55d2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
26 changes: 26 additions & 0 deletions assets/js/SpecRunner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Instructions from https://github.com/TravelTimN/ci-ifd-lead/blob/master/week5-jasmine/jasmine.md -->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zengarden Jasmin Testing</title>
<!-- Jasmine CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.5.0/jasmine.css" type="text/css">
</head>
<body>
<!-- Jasmine JS files -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.6.0/jasmine.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.6.0/jasmine-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.6.0/boot.js"></script>

<!-- Your Source Code (this must come before the tests!) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.0/howler.min.js"></script>
<script src="scripts/app.js"></script>


<!-- Specifications (this must come after the source code!) -->
<script src="specs/appSpecs.js"></script>
</body>
</html>
Empty file removed assets/js/specs/app.js
Empty file.
33 changes: 33 additions & 0 deletions assets/js/specs/appSpecs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe('Meditation App', ()=>{
describe("Streakbar Management", function() {
beforeEach(function() {
localStorage.clear()
});
it("should initialize the streak", function() {
streakInit();
expect(streak).toBe(0);
});
it("should reset Streak if dateLastDone != oneDayAgo", function(){
dateLastDone = setTodayDate();
oneDayAgo = setOneDayAgo();
expect(checkStreak()).toBe(true)
})
it("should store global variables", function(){
expect(countdownleft).toBe(3);
})
});
describe("Format Duration", function() {
it("format 60 seconds to 1:00", function() {
expect(formatDuration(60)).toBe("1:00");
});
it("format 90 seconds to 1:30", function() {
expect(formatDuration(90)).toBe("1:30")
});
it("format 0 seconds to 0:00", function() {
expect(formatDuration(0)).toBe("0:00")
});
it("format 64 seconds to 1:04", function() {
expect(formatDuration(64)).toBe("1:04")
});
});
});

0 comments on commit eba55d2

Please sign in to comment.