mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
Added first few Javascript specs.
This commit is contained in:
parent
453d351633
commit
fadb576d76
1
Gemfile
1
Gemfile
@ -14,6 +14,7 @@ gem 'active_support', require: false
|
||||
|
||||
group :development, :test do
|
||||
gem 'pry'
|
||||
gem 'jasmine'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
||||
@ -25,8 +25,15 @@ GEM
|
||||
dotenv (>= 0.7)
|
||||
thor (>= 0.13.6)
|
||||
hike (1.2.3)
|
||||
jasmine (2.0.0)
|
||||
jasmine-core (~> 2.0.0)
|
||||
phantomjs
|
||||
rack (>= 1.2.1)
|
||||
rake
|
||||
jasmine-core (2.0.0)
|
||||
method_source (0.8.2)
|
||||
multi_json (1.8.2)
|
||||
phantomjs (1.9.7.0)
|
||||
pry (0.9.12.2)
|
||||
coderay (~> 1.0.5)
|
||||
method_source (~> 0.8)
|
||||
@ -91,6 +98,7 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
active_support
|
||||
foreman
|
||||
jasmine
|
||||
pry
|
||||
rspec
|
||||
rspec-mocks
|
||||
|
||||
4
Rakefile
4
Rakefile
@ -1,4 +1,6 @@
|
||||
require 'sinatra/asset_pipeline/task.rb'
|
||||
require './app'
|
||||
require File.expand_path('lib/mpd_client', __dir__)
|
||||
|
||||
Sinatra::AssetPipeline::Task.define! MPDClient
|
||||
require 'jasmine'
|
||||
load 'jasmine/tasks/jasmine.rake'
|
||||
|
||||
21
spec/javascripts/controllers/queue.controller.spec.js
Normal file
21
spec/javascripts/controllers/queue.controller.spec.js
Normal file
@ -0,0 +1,21 @@
|
||||
describe('queue controller', function() {
|
||||
|
||||
var QueueController, scope
|
||||
|
||||
beforeEach(module('mpdClient'))
|
||||
|
||||
beforeEach(inject(function ($controller, $rootScope) {
|
||||
scope = $rootScope.$new()
|
||||
QueueController = $controller('queue', { $scope: scope, api: mockApi })
|
||||
}))
|
||||
|
||||
it('gets queue songs from the API', function () {
|
||||
expect(scope.queueSongs.length).toBe(2)
|
||||
})
|
||||
|
||||
it('sets the currently playing song', function () {
|
||||
scope.updatePlaying(scope.queueSongs[1].id)
|
||||
expect(scope.queueSongs[0].playing).toBe(false)
|
||||
})
|
||||
|
||||
});
|
||||
0
spec/javascripts/helpers/.gitkeep
Normal file
0
spec/javascripts/helpers/.gitkeep
Normal file
2160
spec/javascripts/lib/angular-mocks.js
vendored
Executable file
2160
spec/javascripts/lib/angular-mocks.js
vendored
Executable file
File diff suppressed because it is too large
Load Diff
26
spec/javascripts/mocks/api.mock.js
Normal file
26
spec/javascripts/mocks/api.mock.js
Normal file
@ -0,0 +1,26 @@
|
||||
var mockApi = {
|
||||
getQueue: function () {
|
||||
return {
|
||||
query: function () {
|
||||
return [
|
||||
{ "id": 116,
|
||||
"track": 1,
|
||||
"artist": "Porcupine Tree",
|
||||
"album": "In Absentia",
|
||||
"title": "Drown With Me",
|
||||
"length": 322,
|
||||
"pos": 0,
|
||||
"playing": true },
|
||||
{ "id": 117,
|
||||
"track": 1,
|
||||
"artist": "Porcupine Tree",
|
||||
"album": "In Absentia",
|
||||
"title": "Blackest Eyes",
|
||||
"length": 263,
|
||||
"pos": 1,
|
||||
"playing": false }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
spec/javascripts/support/jasmine.yml
Normal file
120
spec/javascripts/support/jasmine.yml
Normal file
@ -0,0 +1,120 @@
|
||||
# src_files
|
||||
#
|
||||
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
||||
# Default: []
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# src_files:
|
||||
# - lib/source1.js
|
||||
# - lib/source2.js
|
||||
# - dist/**/*.js
|
||||
#
|
||||
src_files:
|
||||
- js/libs/jquery-2.0.3.min.js
|
||||
- js/libs/angular.js
|
||||
- js/libs/angular-resource.js
|
||||
- __spec__/lib/angular-mocks.js
|
||||
- __spec__/mocks/api.mock.js
|
||||
- js/mpd-client.app.js
|
||||
- js/filters/*.js
|
||||
- js/services/*.js
|
||||
- js/controllers/*.js
|
||||
|
||||
# stylesheets
|
||||
#
|
||||
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
||||
# Default: []
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# stylesheets:
|
||||
# - css/style.css
|
||||
# - stylesheets/*.css
|
||||
#
|
||||
stylesheets:
|
||||
- css/**/*.css
|
||||
|
||||
# helpers
|
||||
#
|
||||
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
||||
# Default: ["helpers/**/*.js"]
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# helpers:
|
||||
# - helpers/**/*.js
|
||||
#
|
||||
helpers:
|
||||
- 'helpers/**/*.js'
|
||||
|
||||
# spec_files
|
||||
#
|
||||
# Return an array of filepaths relative to spec_dir to include.
|
||||
# Default: ["**/*[sS]pec.js"]
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# spec_files:
|
||||
# - **/*[sS]pec.js
|
||||
#
|
||||
spec_files:
|
||||
- '**/*[sS]pec.js'
|
||||
|
||||
# src_dir
|
||||
#
|
||||
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
||||
# Default: project root
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# src_dir: public
|
||||
#
|
||||
src_dir: assets
|
||||
|
||||
# spec_dir
|
||||
#
|
||||
# Spec directory path. Your spec_files must be returned relative to this path.
|
||||
# Default: spec/javascripts
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# spec_dir: spec/javascripts
|
||||
#
|
||||
spec_dir:
|
||||
|
||||
# spec_helper
|
||||
#
|
||||
# Ruby file that Jasmine server will require before starting.
|
||||
# Returned relative to your root path
|
||||
# Default spec/javascripts/support/jasmine_helper.rb
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# spec_helper: spec/javascripts/support/jasmine_helper.rb
|
||||
#
|
||||
spec_helper: spec/javascripts/support/jasmine_helper.rb
|
||||
|
||||
# boot_dir
|
||||
#
|
||||
# Boot directory path. Your boot_files must be returned relative to this path.
|
||||
# Default: Built in boot file
|
||||
#
|
||||
# EXAMPLE:
|
||||
#
|
||||
# boot_dir: spec/javascripts/support/boot
|
||||
#
|
||||
boot_dir:
|
||||
|
||||
# boot_files
|
||||
#
|
||||
# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine
|
||||
# Default: Built in boot file
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# boot_files:
|
||||
# - '**/*.js'
|
||||
#
|
||||
boot_files:
|
||||
|
||||
11
spec/javascripts/support/jasmine_helper.rb
Normal file
11
spec/javascripts/support/jasmine_helper.rb
Normal file
@ -0,0 +1,11 @@
|
||||
#Use this file to set/override Jasmine configuration options
|
||||
#You can remove it if you don't need it.
|
||||
#This file is loaded *after* jasmine.yml is interpreted.
|
||||
#
|
||||
#Example: using a different boot file.
|
||||
#Jasmine.configure do |config|
|
||||
# config.boot_dir = '/absolute/path/to/boot_dir'
|
||||
# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
|
||||
#end
|
||||
#
|
||||
|
||||
Loading…
Reference in New Issue
Block a user