-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dutchenkoOleg/upd
Upd
- Loading branch information
Showing
6 changed files
with
143 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "7" | ||
- "6" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Change log | ||
|
||
:back: [README.md](./README.md) | ||
|
||
> _All notable changes to this project will be documented in this file._ | ||
> _This project adheres to [Semantic Versioning](http://semver.org/)._ | ||
--- | ||
|
||
### [1.1.9] - 2017-07-07 | ||
|
||
#### Added | ||
|
||
- this CHANGELOG.md file )) | ||
- test for code style | ||
- test of sorting result, see [./tests/index.js](./tests/index.js) | ||
- [Travis CI](https://travis-ci.org/dutchenkoOleg/gulp-not-supported-file) builds | ||
|
||
#### Changed | ||
|
||
- js code style with accordance to [`happiness`]((https://github.com/JedWatson/happiness)) | ||
|
||
--- |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* > Sorting test | ||
* @module path/to | ||
* @author Oleg Dutchenko <dutchenko.o.wezom@gmail.com> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// ---------------------------------------- | ||
// Imports | ||
// ---------------------------------------- | ||
|
||
const sortCSSmq = require('../'); | ||
|
||
// ---------------------------------------- | ||
// Helpers / Private | ||
// ---------------------------------------- | ||
|
||
// randomize | ||
function shuffleArray (array) { | ||
let newArray = array.concat(); | ||
|
||
for (let i = array.length - 1; i > 0; i--) { | ||
let j = Math.floor(Math.random() * (i + 1)); | ||
let temp = newArray[i]; | ||
|
||
newArray[i] = newArray[j]; | ||
newArray[j] = temp; | ||
} | ||
return newArray; | ||
} | ||
|
||
// ---------------------------------------- | ||
// Public | ||
// ---------------------------------------- | ||
|
||
// correct sorted order | ||
const queries = [ | ||
// min-width/-height -> from smallest to largest | ||
'only screen and (min-width: 320px) and (max-width: 767px)', | ||
'screen and (min-height: 480px)', | ||
'screen and (min-height: 480px) and (min-width: 320px)', | ||
'only screen and (min-width: 640px)', | ||
'screen and (min-width: 1024px)', | ||
'only screen and (min-width: 1280px)', | ||
|
||
// device | ||
'only screen and (min-device-width: 320px) and (max-device-width: 767px)', | ||
|
||
// max-width/-height <- from largest to smallest | ||
'only screen and (max-width: 1023px)', | ||
'only screen and (max-height: 767px) and (min-height: 320px)', | ||
'only screen and (max-width: 767px) and (min-width: 320px)', | ||
'screen and (max-width: 639px)' | ||
]; | ||
|
||
// shuffle it | ||
const random = shuffleArray(queries); | ||
|
||
// sort by module | ||
random.sort(sortCSSmq); | ||
|
||
// make strings for compare | ||
const correct = queries.join(','); | ||
const sorted = random.join(','); | ||
|
||
// lets test | ||
if (correct !== sorted) { | ||
let msg = [ | ||
'', | ||
'ERROR -----------------', | ||
'sortCSSmq result should be same as correct!', | ||
'Correct sort', | ||
`- ${queries.join('\n- ')}`, | ||
'sortCSSmq result:', | ||
`- ${random.join('\n- ')}`, | ||
'' | ||
].join('\n\n'); | ||
|
||
console.log(msg); | ||
process.exit(1); | ||
} |