This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(widgets): Adds simple unit and int tests.
- Sets up Karma to run some simple tests. - Sets up Protractor to run some simple tests. - Protractor tests use the Page Object pattern. Closes GDC-41
- Loading branch information
1 parent
32c76c1
commit b6ad2ae
Showing
19 changed files
with
297 additions
and
75 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,7 +1,11 @@ | ||
dist/ | ||
.idea/ | ||
|
||
node_modules/ | ||
bower_components/ | ||
npm-debug.log | ||
npm-debug.log* | ||
|
||
.idea/ | ||
dist/ | ||
.tmp/ | ||
coverage/ | ||
report/ | ||
|
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,4 +1,3 @@ | ||
<div class="container"> | ||
<h1>NG TS Boilerplate</h1> | ||
<p>Angular + Typescript</p> | ||
<h1>GDC Data Portal</h1> | ||
</div> |
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,56 @@ | ||
describe('Widgets:', function () { | ||
|
||
var WidgetsService, controller, httpBackend; | ||
|
||
// Initialization of the AngularJS application before each test case | ||
beforeEach(module('ngApp.widgets')); | ||
|
||
// Injection of dependencies, $http will be mocked with $httpBackend | ||
beforeEach(inject(function ($httpBackend) { | ||
httpBackend = $httpBackend; | ||
})); | ||
|
||
describe('Controller:', function () { | ||
it('should have widgets', inject(function ($controller) { | ||
// Which HTTP requests do we expect to occur, and how do we response? | ||
var widgets = [ | ||
{"name": "First User"}, | ||
{"name": "Second User"} | ||
]; | ||
|
||
// Starting the controller | ||
var wc = $controller('WidgetsController', {widgets: widgets}); | ||
|
||
// We expect the controller to put the right value onto the scope | ||
expect(wc).to.have.property('widgets').with.length(2); | ||
})); | ||
}); | ||
|
||
describe('Service:', function () { | ||
it('should get all widgets', inject(function (WidgetsService) { | ||
sinon.spy(WidgetsService.ds, 'get'); | ||
|
||
var ws = {hits:[],facets:[],pagination:{}}; | ||
httpBackend.whenGET("/widgets").respond(ws); | ||
|
||
WidgetsService.getWidgets(); | ||
httpBackend.flush(); | ||
|
||
expect(WidgetsService.ds.get).to.have.been.calledOnce; | ||
expect(WidgetsService.ds.get).to.have.been.calledWith(""); | ||
})); | ||
|
||
it('should get one widget by id', inject(function (WidgetsService) { | ||
sinon.spy(WidgetsService.ds, 'get'); | ||
|
||
var w = {}; | ||
httpBackend.whenGET("/widgets/1").respond(w); | ||
|
||
WidgetsService.getWidget(1); | ||
httpBackend.flush(); | ||
|
||
expect(WidgetsService.ds.get).to.have.been.calledOnce; | ||
expect(WidgetsService.ds.get).to.have.been.calledWith(1); | ||
})); | ||
}); | ||
}); |
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,31 @@ | ||
'use strict'; | ||
|
||
var chai, chaiAsPromised, expect, ptor; | ||
|
||
chai = require("chai"); | ||
chaiAsPromised = require('chai-as-promised'); | ||
chai.use(chaiAsPromised); | ||
expect = chai.expect; | ||
|
||
var HomePage = require('./pages/home.po.js'); | ||
|
||
describe('Home:', function () { | ||
var page; | ||
|
||
before(function () { | ||
page = new HomePage(); | ||
ptor = protractor.getInstance(); | ||
}); | ||
|
||
it('should have a page title', function () { | ||
ptor.getTitle().then(function (text) { | ||
expect(text).to.equal("| GDC"); | ||
}); | ||
}); | ||
|
||
it('should have a header', function () { | ||
page.header.getText().then(function(text){ | ||
expect(text).to.equal('GDC Data Portal'); | ||
}); | ||
}); | ||
}); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var HomePage = function () { | ||
browser.get(''); | ||
}; | ||
|
||
HomePage.prototype = Object.create({}, { | ||
header: { | ||
get: function () { | ||
return element(by.css('h1')); | ||
}} | ||
}); | ||
|
||
module.exports = HomePage; |
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,14 @@ | ||
'use strict'; | ||
|
||
var WidgetPage = function () { | ||
browser.get('widgets/PR1'); | ||
}; | ||
|
||
WidgetPage.prototype = Object.create({}, { | ||
header: { | ||
get: function () { | ||
return element(by.css('h1')); | ||
}} | ||
}); | ||
|
||
module.exports = WidgetPage; |
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,24 @@ | ||
'use strict'; | ||
|
||
var widgetsRepeater = by.repeater('w in wsc.widgets.hits'); | ||
|
||
var WidgetsPage = function () { | ||
browser.get('widgets'); | ||
}; | ||
|
||
WidgetsPage.prototype = Object.create({}, { | ||
header: { | ||
get: function () { | ||
return element(by.css('h1')); | ||
}}, | ||
widgets: { | ||
get: function () { | ||
return element.all(widgetsRepeater); | ||
}}, | ||
widget: { | ||
value: function (id, field) { | ||
return element(widgetsRepeater.row(id).column('w.' + field)); | ||
}} | ||
}); | ||
|
||
module.exports = WidgetsPage; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
var chai, chaiAsPromised, expect, ptor; | ||
|
||
chai = require("chai"); | ||
chaiAsPromised = require('chai-as-promised'); | ||
chai.use(chaiAsPromised); | ||
expect = chai.expect; | ||
|
||
var WidgetPage = require('./pages/widget.po.js'); | ||
|
||
describe('Widget:', function () { | ||
var page; | ||
|
||
before(function () { | ||
page = new WidgetPage(); | ||
ptor = protractor.getInstance(); | ||
}); | ||
|
||
it('should have a page title', function () { | ||
ptor.getTitle().then(function (text) { | ||
expect(text).to.equal("| GDC"); | ||
}); | ||
}); | ||
|
||
it('should have a header', function () { | ||
page.header.getText().then(function(text){ | ||
expect(text).to.equal('PR1'); | ||
}); | ||
}); | ||
}); |
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,43 @@ | ||
'use strict'; | ||
|
||
var chai, chaiAsPromised, expect, ptor; | ||
|
||
chai = require("chai"); | ||
chaiAsPromised = require('chai-as-promised'); | ||
chai.use(chaiAsPromised); | ||
expect = chai.expect; | ||
|
||
var WidgetsPage = require('./pages/widgets.po.js'); | ||
|
||
describe('Widgets:', function () { | ||
var page; | ||
|
||
before(function () { | ||
page = new WidgetsPage(); | ||
ptor = protractor.getInstance(); | ||
}); | ||
|
||
it('should have a page title', function () { | ||
ptor.getTitle().then(function (text) { | ||
expect(text).to.equal("| GDC"); | ||
}); | ||
}); | ||
|
||
it('should have a header', function () { | ||
page.header.getText().then(function (text) { | ||
expect(text).to.equal('Widgets'); | ||
}); | ||
}); | ||
|
||
describe('List:', function () { | ||
it('should show a list widgets', function () { | ||
page.widgets.then(function (rows) { | ||
expect(rows.length).to.equal(5); | ||
}); | ||
|
||
page.widget(0, 'id').getText().then(function (row) { | ||
expect(row).to.equal('PR1'); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.