Skip to content

Commit 9b434d8

Browse files
committed
Merge branch 'master' into selectTest
2 parents 1d19ba7 + 655446d commit 9b434d8

File tree

7 files changed

+69
-16
lines changed

7 files changed

+69
-16
lines changed

_SpecRunner.html

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232

3333
<script src="tests/spec/select/selectSpec.js"></script>
3434

35+
<script src="tests/spec/collapsible/collapsibleSpec.js"></script>
36+
37+
<script src="tests/spec/toast/toastSpec.js"></script>
38+
3539
<script src=".grunt/grunt-contrib-jasmine/reporter.js"></script>
3640

3741

bin/materialize.css

+1-5
Original file line numberDiff line numberDiff line change
@@ -5879,16 +5879,12 @@ small {
58795879
bottom: 0%; } }
58805880
@media only screen and (min-width : 601px) and (max-width : 992px) {
58815881
#toast-container {
5882-
min-width: 30%;
58835882
left: 5%;
5884-
right: 5%;
58855883
bottom: 7%; } }
58865884
@media only screen and (min-width : 993px) {
58875885
#toast-container {
5888-
min-width: 8%;
58895886
top: 10%;
5890-
right: 7%;
5891-
left: 7%; } }
5887+
right: 7%; } }
58925888

58935889
.toast {
58945890
border-radius: 2px;

css/ghpages-materialize.css

+1-5
Original file line numberDiff line numberDiff line change
@@ -5879,16 +5879,12 @@ small {
58795879
bottom: 0%; } }
58805880
@media only screen and (min-width : 601px) and (max-width : 992px) {
58815881
#toast-container {
5882-
min-width: 30%;
58835882
left: 5%;
5884-
right: 5%;
58855883
bottom: 7%; } }
58865884
@media only screen and (min-width : 993px) {
58875885
#toast-container {
5888-
min-width: 8%;
58895886
top: 10%;
5890-
right: 7%;
5891-
left: 7%; } }
5887+
right: 7%; } }
58925888

58935889
.toast {
58945890
border-radius: 2px;

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
"jasmine-jquery": "^2.1.1",
3636
"jquery": "^2.1.4",
3737
"node-sass": "^2.1.1",
38-
"phantomjs": "^1.9.18",
39-
"qunit": "^0.7.6"
38+
"phantomjs": "^1.9.18"
4039
},
4140
"scripts": {
4241
"test": "grunt travis --verbose"

sass/components/_toast.scss

-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@
88
bottom: 0%;
99
}
1010
@media #{$medium-only} {
11-
min-width: 30%;
1211
left: 5%;
13-
right: 5%;
1412
bottom: 7%;
1513
}
1614
@media #{$large-and-up} {
17-
min-width: 8%;
1815
top: 10%;
1916
right: 7%;
20-
left: 7%;
2117
}
2218
}
2319

tests/spec/collapsible/collapsibleSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
jasmine.getFixtures().fixturesPath = 'tests/spec';
22

3+
34
describe( "Collapsible Plugin", function () {
45
var collapsible, accordion;
56

tests/spec/toast/toastSpec.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
describe( 'Toasts:', function() {
2+
var toastOutDuration = 375;
3+
var toastInDuration = 300;
4+
var toast;
5+
6+
describe('Toast javascript functions', function() {
7+
// Toast out animation duration does not count as part of its timer.
8+
it('should display and remove a toast', function(done) {
9+
Materialize.toast('Test toast', toastInDuration);
10+
11+
setTimeout(function() {
12+
toast = $('.toast');
13+
expect(toast.length).toBe(1);
14+
expect(toast).toBeVisible();
15+
expect(toast.text()).toBe('Test toast');
16+
setTimeout(function() {
17+
toast = $('.toast');
18+
expect(toast).toBeVisible();
19+
expect(toast.length).toBe(1, 'because toast duration still on going');
20+
setTimeout(function() {
21+
toast = $('.toast');
22+
expect(toast.length).toBe(0, 'because toast should be removed by now');
23+
done();
24+
}, toastOutDuration + 90); // .1s leeway is given
25+
}, 10);
26+
}, toastInDuration);
27+
});
28+
29+
it('Opens a toast with HTML content', function() {
30+
var $toastContent = $('<span>I am toast content</span>');
31+
Materialize.toast($toastContent, 400);
32+
toast = $('.toast');
33+
expect(toast.first('span').text()).toBe('I am toast content');
34+
expect(toast.first('span').text()).not.toBe('I am toast')
35+
});
36+
37+
it('Toasts should call the callback function when dismissed',
38+
function(done) {
39+
var boolObj = {wasCalled: false};
40+
var callback = function() {
41+
boolObj.wasCalled = true;
42+
};
43+
Materialize.toast('I am a toast', 100, '', callback);
44+
setTimeout(function() {
45+
expect(boolObj.wasCalled).toBe(true,
46+
'because the callback set it to true');
47+
done();
48+
}, 500);
49+
});
50+
51+
it('Apply two custom class to a toast', function() {
52+
Materialize.toast('Hi', 400, 'round flat');
53+
toast = $('.toast');
54+
expect(toast.closest('.round.flat').length).toBe(1,
55+
'because the class parameter was passed with two classes');
56+
});
57+
58+
});
59+
60+
61+
});

0 commit comments

Comments
 (0)