Tested HTML involved methods in xos-utils
diff --git a/xos/core/xoslib/karma.conf.js b/xos/core/xoslib/karma.conf.js
index fd5538f..d78c020 100644
--- a/xos/core/xoslib/karma.conf.js
+++ b/xos/core/xoslib/karma.conf.js
@@ -29,7 +29,7 @@
'spec/helpers/jasmine-jquery.js',
'spec/**/*.test.js',
- 'spec/fixture/**/*.html'
+ 'spec/**/*.html'
],
diff --git a/xos/core/xoslib/spec/helpers/jasmine-jquery.js b/xos/core/xoslib/spec/helpers/jasmine-jquery.js
index 8d35a87..7713331 100644
--- a/xos/core/xoslib/spec/helpers/jasmine-jquery.js
+++ b/xos/core/xoslib/spec/helpers/jasmine-jquery.js
@@ -136,6 +136,8 @@
htmlText = $xhr.responseText
}
}).fail(function ($xhr, status, err) {
+ console.log($xhr.responseText);
+ console.log($xhr.getAllResponseHeaders());
throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
})
diff --git a/xos/core/xoslib/spec/xoslib/make_same_width.html b/xos/core/xoslib/spec/xoslib/make_same_width.html
new file mode 100644
index 0000000..8227c99
--- /dev/null
+++ b/xos/core/xoslib/spec/xoslib/make_same_width.html
@@ -0,0 +1,5 @@
+<div class="container">
+ <div style="width: 200px"></div>
+ <div style="width: 300px"></div>
+ <div style="width: 400px"></div>
+</div>
\ No newline at end of file
diff --git a/xos/core/xoslib/spec/xoslib/table_rows.html b/xos/core/xoslib/spec/xoslib/table_rows.html
new file mode 100644
index 0000000..417108d
--- /dev/null
+++ b/xos/core/xoslib/spec/xoslib/table_rows.html
@@ -0,0 +1,19 @@
+<div class="container">
+ <table class="test-table" border="2">
+ <tr>
+ <td height="150">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sequi eaque voluptatum, itaque dolor ut animi ea, laboriosam nobis perspiciatis ducimus asperiores excepturi. Architecto earum, harum nesciunt libero maxime repellat dicta.</td>
+ </tr>
+ <tr>
+ <td height="150">Autem esse, accusantium adipisci, aliquid debitis inventore alias error dolores veniam nesciunt possimus animi dolorum magnam nostrum et asperiores id natus, deleniti ullam illum magni cupiditate suscipit hic. Temporibus, non?</td>
+ </tr>
+ <tr>
+ <td height="150">Tempore sapiente sed laborum commodi explicabo praesentium, molestiae repellendus sit minima magni natus doloremque eius vel voluptatem officiis, blanditiis incidunt nobis! Aut, dolorum, impedit assumenda inventore blanditiis voluptas mollitia nihil.</td>
+ </tr>
+ <tr>
+ <td height="150">Quae esse, earum tenetur, quam at iure cumque unde suscipit corporis, nemo voluptatibus. Ducimus, ratione quidem ut earum? Error, esse quae. Quis ea vero, tempore minus voluptates possimus iure deleniti.</td>
+ </tr>
+ <tr>
+ <td height="150">Asperiores sequi dignissimos doloribus commodi tenetur blanditiis eaque accusantium, hic molestias quas modi minima ratione reiciendis ut id voluptatem eveniet, culpa placeat? Dolor soluta, non cumque adipisci architecto sapiente ullam!</td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
diff --git a/xos/core/xoslib/spec/xoslib/template_from_id.html b/xos/core/xoslib/spec/xoslib/template_from_id.html
new file mode 100644
index 0000000..02dcb96
--- /dev/null
+++ b/xos/core/xoslib/spec/xoslib/template_from_id.html
@@ -0,0 +1,7 @@
+<script type="text/template" id="static-test">
+ <p>Test Template</p>
+</script>
+
+<script type="text/template" id="dynamic-test">
+ <p>Test <%= stuff %></p>
+</script>
\ No newline at end of file
diff --git a/xos/core/xoslib/spec/xoslib/utils.test.js b/xos/core/xoslib/spec/xoslib/utils.test.js
index 6f395c1..7009c00 100644
--- a/xos/core/xoslib/spec/xoslib/utils.test.js
+++ b/xos/core/xoslib/spec/xoslib/utils.test.js
@@ -1,6 +1,14 @@
'use strict';
describe('The XOS Lib Utilities', function() {
+
+ var f;
+
+ beforeEach(() => {
+ f = jasmine.getFixtures();
+ f.fixturesPath = 'base/spec/xoslib';
+ });
+
describe('The idInArray method', function() {
it('should match a string ID', () => {
let res = idInArray('1', [1, 2, 3]);
@@ -19,8 +27,19 @@
});
describe('The templateFromId method', () => {
- xit('should behave...', () => {
-
+
+ beforeEach(() => {
+ f.load('template_from_id.html');
+ });
+
+ it('should load a static template', () => {
+ let st = templateFromId('#static-test');
+ expect($(st()).text()).toEqual('Test Template');
+ });
+
+ it('should load a dynamic template', () => {
+ let dn = templateFromId('#dynamic-test');
+ expect($(dn({stuff: 'Template'})).text()).toEqual('Test Template');
});
});
@@ -46,8 +65,19 @@
});
describe('The limitTableRows', () => {
- xit('should be tested', () => {
-
+
+ beforeEach(() => {
+ f.load('table_rows.html');
+ });
+
+ it('should limit the table container height', () => {
+
+ // table border = 2, td height = 150, see fixture html
+ // resulting table height: 308
+ // .conatiner height: 308 + 2 (table border top)
+
+ limitTableRows('table.test-table', 2);
+ expect($('.container')[0]).toHaveCss({height: '310px'});
});
});
@@ -116,7 +146,7 @@
describe('The all_options method', () => {
beforeEach(() => {
- jasmine.getFixtures().set(`
+ f.set(`
<select id="test-select">
<option value="1">1</option>
<option value="2">2</option>
@@ -132,13 +162,21 @@
});
describe('The make_same_width method', () => {
- xit('should be tested', () => {
-
+
+ beforeEach(() => {
+ f.load('make_same_width.html');
+ });
+
+ it('should set elements to same width', () => {
+ make_same_width('.container', 'div');
+ $('.container div').each(function(){
+ expect($(this)).toHaveCss({width: '400px'});
+ });
});
});
describe('The strip_scripts method', () => {
- it('should be tested', () => {
+ it('should strip scripts tag', () => {
const mockHtml = `
<!DOCTYPE html>
<html lang="en">