Permalink
Browse files

started sideNav tests

  • Loading branch information...
1 parent 84f204d commit bee646dcd37734c888f22c961aaaf79960eba29a @acburst acburst committed Dec 29, 2016
Showing with 61 additions and 0 deletions.
  1. +2 −0 _SpecRunner.html
  2. +16 −0 tests/spec/sideNav/sideNavFixture.html
  3. +43 −0 tests/spec/sideNav/sideNavSpec.js
View
@@ -44,6 +44,8 @@
<script src="tests/spec/select/selectSpec.js"></script>
+ <script src="tests/spec/sideNav/sideNavSpec.js"></script>
+
<script src="tests/spec/tabs/tabsSpec.js"></script>
<script src="tests/spec/toast/toastSpec.js"></script>
@@ -0,0 +1,16 @@
+<ul id="slide-out" class="side-nav">
+ <li><div class="userView">
+ <div class="background">
+ <img src="images/office.jpg">
+ </div>
+ <a href="#!user"><img class="circle" src="images/yuna.jpg"></a>
+ <a href="#!name"><span class="white-text name">John Doe</span></a>
+ <a href="#!email"><span class="white-text email">jdandturk@gmail.com</span></a>
+ </div></li>
+ <li><a href="#!"><i class="material-icons">cloud</i>First Link With Icon</a></li>
+ <li><a href="#!">Second Link</a></li>
+ <li><div class="divider"></div></li>
+ <li><a class="subheader">Subheader</a></li>
+ <li><a class="waves-effect" href="#!">Third Link With Waves</a></li>
+</ul>
+<a href="#" data-activates="slide-out" class="button-collapse"><i class="material-icons">menu</i></a>
@@ -0,0 +1,43 @@
+describe("SideNav Plugin", function () {
+ beforeEach(function() {
+ loadFixtures('sideNav/sideNavFixture.html');
+ $(".button-collapse").sideNav();
+ });
+
+ describe("SideNav", function () {
+ var normalActivator, normalSideNav;
+
+ beforeEach(function() {
+ normalActivator = $('.button-collapse');
+ normalSideNav = $('.side-nav');
+ });
+
+ it("should open sideNav from left", function (done) {
+ var sideNavRect = normalSideNav[0].getBoundingClientRect();
+ var overlay = $('#sidenav-overlay');
+ var dragTarget = $('.drag-target[data-sidenav="' + normalActivator.attr('data-activates') + '"]');
+
+ expect(dragTarget.length).toEqual(1, 'Should generate only one dragTarget.');
+ expect(overlay.length).toEqual(0, 'Overlay should not be generated before sideNav is opened.');
+ expect(sideNavRect.left).toEqual(-sideNavRect.width, 'Should be hidden before sideNav is opened.');
+
+ normalActivator.click();
+
+ setTimeout(function() {
+ sideNavRect = normalSideNav[0].getBoundingClientRect();
+ overlay = $('#sidenav-overlay');
+ expect(overlay.length).toEqual(1, 'Should generate only one overlay.');
+ expect(sideNavRect.left).toEqual(0, 'Should be shown after sideNav is closed.');
+
+ overlay.click();
+
+ setTimeout(function() {
+ overlay = $('#sidenav-overlay');
+ expect(overlay.length).toEqual(0, 'Overlay should be removed after sideNav is closed.');
+
+ done();
+ }, 500);
+ }, 500);
+ });
+ });
+});

0 comments on commit bee646d

Please sign in to comment.