-
Notifications
You must be signed in to change notification settings - Fork 6
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 #4 from ianmcgregor/develop
🐛 Fix group api issue and update tests - fixes #3
- Loading branch information
Showing
10 changed files
with
106 additions
and
41 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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
sudo: false | ||
dist: trusty | ||
language: node_js | ||
node_js: | ||
- 0.10 | ||
- 6 | ||
addons: | ||
firefox: "30.0" | ||
apt: | ||
packages: | ||
- google-chrome-stable | ||
before_install: | ||
- 'npm install -g karma-cli' | ||
before_script: | ||
- export CHROME_BIN=chromium-browser | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
- sleep 3 | ||
before_script: | ||
- npm i -g karma karma-cli |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
{ | ||
"image": [ | ||
"http://placekitten.com/g/200/300", | ||
"http://placekitten.com/1000/1000", | ||
"http://placekitten.com/g/400/200", | ||
"http://placekitten.com/g/200/150" | ||
"https://ianmcgregor.co/prototypes/images/cat_01.jpg", | ||
"https://ianmcgregor.co/prototypes/images/cat_02.jpg", | ||
"https://ianmcgregor.co/prototypes/images/cat_03.jpg", | ||
"https://ianmcgregor.co/prototypes/images/cat_04.jpg" | ||
], | ||
"audio": [ | ||
{ | ||
"ogg": "https://dl.dropboxusercontent.com/u/15470024/prototypes/audio/music.ogg", | ||
"mp3": "https://dl.dropboxusercontent.com/u/15470024/prototypes/audio/music.mp3" | ||
"ogg": "https://ianmcgregor.co/prototypes/audio/music.ogg", | ||
"mp3": "https://ianmcgregor.co/prototypes/audio/music.mp3" | ||
} | ||
], | ||
"video": [ | ||
{ | ||
"mp4": "https://dl.dropboxusercontent.com/u/15470024/prototypes/video/counter.mp4", | ||
"webm": "https://dl.dropboxusercontent.com/u/15470024/prototypes/video/counter.webm" | ||
"mp4": "https://ianmcgregor.co/prototypes/video/counter.mp4", | ||
"webm": "https://ianmcgregor.co/prototypes/video/counter.webm" | ||
} | ||
], | ||
"json": [ | ||
"https://dl.dropboxusercontent.com/u/15470024/prototypes/test/test.json" | ||
"https://ianmcgregor.co/prototypes/test/test.json" | ||
], | ||
"text": [ | ||
"https://dl.dropboxusercontent.com/u/15470024/prototypes/video/tracking/tracking_01.txt" | ||
"https://ianmcgregor.co/prototypes/video/tracking/tracking_01.txt" | ||
] | ||
} |
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,61 @@ | ||
const assetsLoader = require('../src/index.js'); | ||
const files = require('./files.js'); | ||
|
||
describe('asset loader', () => { | ||
|
||
describe('group', () => { | ||
|
||
let complete = false; | ||
let loadProgress = 0; | ||
let groupA = null; | ||
let groupB = null; | ||
|
||
const loader = assetsLoader() | ||
.add({ | ||
id: 'groupA', | ||
assets: files.images | ||
}) | ||
.add({ | ||
id: 'groupB', | ||
assets: [files.json] | ||
}); | ||
|
||
beforeEach(function(done) { | ||
if (complete) { | ||
done(); | ||
return; | ||
} | ||
loader | ||
.on('progress', function(progress) { | ||
loadProgress = progress; | ||
}) | ||
.on('complete', () => { | ||
complete = true; | ||
groupA = loader.get('groupA'); | ||
groupB = loader.get('groupB'); | ||
done(); | ||
}) | ||
.on('error', function(error) { | ||
console.log(error); | ||
}) | ||
.start(); | ||
}); | ||
|
||
it('should have finished loading', () => { | ||
expect(complete).equals(true); | ||
expect(loadProgress).to.eql(1); | ||
}); | ||
|
||
it('should have groupA', () => { | ||
expect(groupA).to.exist; | ||
expect(groupA.get()).to.have.lengthOf(2); | ||
expect(groupA.get()[0]).to.have.property('type', 'jpg'); | ||
}); | ||
|
||
it('should have groupB', () => { | ||
expect(groupB).to.exist; | ||
expect(groupB.get()).to.have.lengthOf(1); | ||
expect(groupB.get()[0]).to.have.property('type', 'json'); | ||
}); | ||
}); | ||
}); |