-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #45 from frankiefu/master
add unit tests to cover more components and the latest sugaring in g-components
- Loading branch information
Showing
11 changed files
with
333 additions
and
23 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,40 @@ | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('g-ajax', function() { | ||
var ajax; | ||
|
||
setup(function() { | ||
ajax = document.createElement('g-ajax'); | ||
work.appendChild(ajax); | ||
// init properties | ||
ajax.url = 'http://gdata.youtube.com/feeds/api/videos/'; | ||
ajax.params = '{"alt":"json", "q":"chrome"}'; | ||
ajax.handleAs = 'json'; | ||
}); | ||
|
||
teardown(function() { | ||
work.textContent = ''; | ||
}); | ||
|
||
test('go', function(done) { | ||
ajax.go(); | ||
ajax.addEventListener('response', function(e) { | ||
var r = e.detail.response; | ||
expect(r.feed.entry.length).to.be.greaterThan(1); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('auto', function(done) { | ||
ajax.auto = true; | ||
ajax.addEventListener('response', function(e) { | ||
var r = e.detail.response; | ||
expect(r.feed.entry.length).to.be.greaterThan(1); | ||
done(); | ||
}); | ||
}); | ||
}); |
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,37 @@ | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('g-icon-button', function() { | ||
var iconButton; | ||
|
||
setup(function() { | ||
iconButton = document.createElement('g-icon-button'); | ||
work.appendChild(iconButton); | ||
}); | ||
|
||
teardown(function() { | ||
work.textContent = ''; | ||
}); | ||
|
||
suite('attributes', function() { | ||
test('src', function(done) { | ||
var src = 'http://foo.com/bar.png'; | ||
iconButton.src = src; | ||
async(function() { | ||
var icon = shadowQuery(iconButton, 'g-icon'); | ||
expect(icon.src).to.be(src); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('active', function() { | ||
iconButton.active = true; | ||
expect(iconButton.classList.contains('selected')).to.be(true); | ||
iconButton.active = false; | ||
expect(iconButton.classList.contains('selected')).to.be(false); | ||
}); | ||
}); | ||
}); |
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,40 @@ | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('g-menu-item', function() { | ||
var item; | ||
|
||
setup(function() { | ||
item = document.createElement('g-menu-item'); | ||
work.appendChild(item); | ||
}); | ||
|
||
teardown(function() { | ||
work.textContent = ''; | ||
}); | ||
|
||
suite('attributes', function() { | ||
test('src', function(done) { | ||
var src = 'http://foo.com/bar.png'; | ||
item.src = src; | ||
async(function() { | ||
var icon = shadowQuery(item, 'g-icon'); | ||
expect(icon.src).to.be(src); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('label', function(done) { | ||
var label = 'mylabel'; | ||
item.label = label; | ||
async(function() { | ||
var span = shadowQuery(item, 'span'); | ||
expect(span.textContent).to.be(label); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.