Skip to content

Commit ca1f485

Browse files
committed
Added first test
1 parent 027e170 commit ca1f485

11 files changed

+238
-6
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "test/components"
3+
}

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.sass-cache
22
.DS_Store
3-
/node_modules/
3+
/node_modules/
4+
/test/components/
5+
/test/jquery.breakpoint.js
6+
/test/style.css

Gruntfile.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
5+
// load all grunt tasks
6+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
7+
8+
grunt.initConfig({
9+
watch: {
10+
js: {
11+
files: '<%= jshint.files.src %>',
12+
tasks: ['jshint']
13+
}
14+
},
15+
connect: {
16+
server: {
17+
options: {
18+
// keepalive: true,
19+
base: 'test/'
20+
}
21+
}
22+
},
23+
jshint: {
24+
options: {
25+
bitwise: true,
26+
camelcase: true,
27+
curly: true,
28+
eqeqeq: true,
29+
forin: true,
30+
immed: true,
31+
indent: 4,
32+
latedef: true,
33+
noempty: true,
34+
trailing: true,
35+
undef: true,
36+
unused: true,
37+
quotmark: 'single',
38+
jquery: true,
39+
devel: false,
40+
browser: true,
41+
globals: {
42+
define: true,
43+
}
44+
},
45+
files: {
46+
src: [
47+
'jquery.breakpoint.js'
48+
]
49+
}
50+
},
51+
sass: {
52+
test: {
53+
options: {
54+
style: 'expanded'
55+
},
56+
src: ['./test/sass/style.scss'],
57+
dest: './test/style.css'
58+
}
59+
},
60+
uglify: {
61+
'./test/jquery.breakpoint.js': './jquery.breakpoint.js'
62+
},
63+
qunit: {
64+
all: {
65+
options: {
66+
urls: [
67+
'http://localhost:8000/index.html'
68+
] }
69+
}
70+
}
71+
});
72+
73+
// for dev we need to lint js and compile sass
74+
grunt.registerTask('default', [
75+
'jshint',
76+
'uglify',
77+
'sass:test',
78+
'connect',
79+
'qunit'
80+
]);
81+
};

bower.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
"version": "4.3.1",
44
"author": "Les James",
55
"homepage": "https://github.com/lesjames/breakpoint",
6-
"ignore": ["**/*.md"],
7-
"scripts": [
8-
"jquery.breakpoint.js"
9-
],
10-
"styles": [
6+
"ignore": ["**/*.md", "./test/**/*", "Gruntfile.js", "package.json"],
7+
"main": [
8+
"jquery.breakpoint.js",
119
"./breakpoint/_breakpoint.scss",
1210
"./breakpoint/_core.scss",
1311
"./breakpoint/_grid.scss"

jquery.breakpoint.js

+3
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@
211211

212212
// if no images or if applied to the document trigger immediately
213213
if ( !$images.length || $this[0] === document ) {
214+
215+
// make sure the breakpoint deferred is resolved first
214216
ready.done(doneLoading);
217+
215218
} else {
216219

217220
// bind the imagesLoaded event to images and then run breakpoint on each on

package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"devDependencies": {
3+
"grunt": "~0.4.1",
4+
"grunt-contrib-jshint": "~0.4.3",
5+
"grunt-contrib-watch": "~0.4.0",
6+
"grunt-contrib-sass": "~0.3.0",
7+
"grunt-contrib-uglify": "~0.2.0",
8+
"grunt-contrib-qunit": "~0.2.1",
9+
"grunt-contrib-connect": "~0.3.0",
10+
"matchdep": "~0.1.1"
11+
},
12+
"engines": {
13+
"node": ">=0.8.0"
14+
}
15+
}

test/index.html

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
5+
<meta charset="utf-8">
6+
7+
<title>Breakpoint Test Page</title>
8+
9+
<meta name="viewport" content="width=device-width">
10+
11+
<link rel="stylesheet" href="/style.css">
12+
<link rel="stylesheet" href="/components/qunit/qunit.css">
13+
<script src="/components/jquery/jquery.js"></script>
14+
<script src="/components/qunit/qunit.js"></script>
15+
<script src="/jquery.breakpoint.js"></script>
16+
17+
18+
</head>
19+
<body>
20+
21+
22+
<img data-small="small.jpg" data-medium="medium.jpg">
23+
<div id="qunit"></div>
24+
25+
<script>
26+
27+
test('Small image by default', function() {
28+
29+
expect(1);
30+
31+
var $img = $('img');
32+
$img.breakpoint();
33+
34+
equal( $img.attr('src'), 'small.jpg', 'defaults to small image' );
35+
36+
});
37+
38+
</script>
39+
40+
</body>
41+
</html>

test/sass/_config.scss

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Grid Variables
2+
// ==========================================================================
3+
4+
$grid-column: 60px;
5+
$grid-gutter: 20px;
6+
$base-font-size: 16px;
7+
8+
// generate visual grid overlay on class .grid-overlay
9+
$grid-overlay: false;
10+
11+
// fallback breakpoint (column count for < IE9)
12+
$ie-support: false;
13+
14+
// label for your mobile first breakpoint
15+
$breakpoint-list: 'small';
16+
17+
// Path to server's static files directory
18+
// Do not use a trailing slash
19+
$static-path: '..';
20+
21+
// Project Variables
22+
// ==========================================================================

test/sass/_reset.scss

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* http://meyerweb.com/eric/tools/css/reset/
2+
v2.0 | 20110126
3+
License: none (public domain)
4+
*/
5+
6+
html, body, div, span, applet, object, iframe,
7+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8+
a, abbr, acronym, address, big, cite, code,
9+
del, dfn, em, img, ins, kbd, q, s, samp,
10+
small, strike, strong, sub, sup, tt, var,
11+
b, u, i, center,
12+
dl, dt, dd, ol, ul, li,
13+
fieldset, form, label, legend,
14+
table, caption, tbody, tfoot, thead, tr, th, td,
15+
article, aside, canvas, details, embed,
16+
figure, figcaption, footer, header, hgroup,
17+
menu, nav, output, ruby, section, summary,
18+
time, mark, audio, video {
19+
margin: 0;
20+
padding: 0;
21+
border: 0;
22+
font-size: 100%;
23+
font: inherit;
24+
vertical-align: baseline;
25+
}
26+
/* HTML5 display-role reset for older browsers */
27+
article, aside, details, figcaption, figure,
28+
footer, header, hgroup, menu, nav, section {
29+
display: block;
30+
}
31+
body {
32+
line-height: 1;
33+
}
34+
ol, ul {
35+
list-style: none;
36+
}
37+
blockquote, q {
38+
quotes: none;
39+
}
40+
blockquote:before, blockquote:after,
41+
q:before, q:after {
42+
content: '';
43+
content: none;
44+
}
45+
table {
46+
border-collapse: collapse;
47+
border-spacing: 0;
48+
}

test/sass/_structure.scss

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Structure
2+
// =============================================================================
3+
4+
5+
@include breakpoint(8, $label: 'medium');

test/sass/style.scss

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// project specific variables and mixins and reset config
2+
@import 'config';
3+
4+
// defaults to hard reset but you can paste normalize there
5+
@import 'reset';
6+
7+
@import '../../breakpoint/breakpoint';
8+
9+
// sturcture loaded last for proper media query cascading
10+
@import 'structure';
11+
12+
// create breakpoint label list
13+
body::after { content: "#{$breakpoint-list}"; display: none; }

0 commit comments

Comments
 (0)