Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Store
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Store
Commits
d8b3ba7e
Commit
d8b3ba7e
authored
Aug 19, 2016
by
Jesús Rodríguez
Committed by
GitHub
Aug 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update specs to TestBed (#184)
parent
6ce71a08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
42 deletions
+32
-42
app/app.component.spec.ts
app/app.component.spec.ts
+15
-23
karma-test-shim.js
karma-test-shim.js
+15
-18
karma.conf.js
karma.conf.js
+2
-1
No files found.
app/app.component.spec.ts
View file @
d8b3ba7e
/* tslint:disable:no-unused-variable */
import
{
AppComponent
}
from
'
./app.component
'
;
import
{
async
,
inject
}
from
'
@angular/core/testing
'
;
import
{
TestComponentBuilder
}
from
'
@angular/core/testing
'
;
import
{
TestBed
}
from
'
@angular/core/testing
'
;
import
{
By
}
from
'
@angular/platform-browser
'
;
import
{
provide
}
from
'
@angular/core
'
;
import
{
ViewMetadata
}
from
'
@angular/core
'
;
//////// SPECS /////////////
...
...
@@ -19,27 +15,23 @@ describe('Smoke test', () => {
});
describe
(
'
AppComponent with TCB
'
,
function
()
{
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
AppComponent
]});
});
it
(
'
should instantiate component
'
,
async
(
inject
([
TestComponentBuilder
],
(
tcb
:
TestComponentBuilder
)
=>
{
tcb
.
createAsync
(
AppComponent
).
then
(
fixture
=>
{
expect
(
fixture
.
componentInstance
instanceof
AppComponent
).
toBe
(
true
,
'
should create AppComponent
'
);
});
})));
it
(
'
should have expected <h1> text
'
,
async
(
inject
([
TestComponentBuilder
],
(
tcb
:
TestComponentBuilder
)
=>
{
tcb
.
createAsync
(
AppComponent
).
then
(
fixture
=>
{
// fixture.detectChanges(); // would need to resolve a binding but we don't have a binding
it
(
'
should instantiate component
'
,
()
=>
{
let
fixture
=
TestBed
.
createComponent
(
AppComponent
);
expect
(
fixture
.
componentInstance
instanceof
AppComponent
).
toBe
(
true
,
'
should create AppComponent
'
);
});
let
h1
=
fixture
.
debugElement
.
query
(
el
=>
el
.
name
===
'
h1
'
).
nativeElement
;
// it works
it
(
'
should have expected <h1> text
'
,
()
=>
{
let
fixture
=
TestBed
.
createComponent
(
AppComponent
);
fixture
.
detectChanges
();
h1
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
h1
'
)).
nativeElement
;
// preferred
let
h1
=
fixture
.
debugElement
.
query
(
el
=>
el
.
name
===
'
h1
'
).
nativeElement
;
// it works
expect
(
h1
.
innerText
).
toMatch
(
/angular 2 app/i
,
'
<h1> should say something about "Angular 2 App"
'
);
});
h1
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
h1
'
)).
nativeElement
;
// preferred
})));
expect
(
h1
.
innerText
).
toMatch
(
/angular 2 app/i
,
'
<h1> should say something about "Angular 2 App"
'
);
});
});
karma-test-shim.js
View file @
d8b3ba7e
...
...
@@ -28,27 +28,24 @@ System.config({
});
System
.
import
(
'
systemjs.config.js
'
)
.
then
(
function
()
{
return
Promise
.
all
([
.
then
(()
=>
Promise
.
all
([
System
.
import
(
'
@angular/core/testing
'
),
System
.
import
(
'
@angular/platform-browser-dynamic/testing
'
)
])
})
.
then
(
function
(
providers
)
{
var
testing
=
providers
[
0
];
var
testingBrowser
=
providers
[
1
];
testing
.
setBaseTestProviders
(
testingBrowser
.
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS
,
testingBrowser
.
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
);
]))
.
then
((
providers
)
=>
{
var
coreTesting
=
providers
[
0
];
var
browserTesting
=
providers
[
1
];
coreTesting
.
TestBed
.
initTestEnvironment
(
browserTesting
.
BrowserDynamicTestingModule
,
browserTesting
.
platformBrowserDynamicTesting
());
})
.
then
(
function
()
{
// Finally, load all spec files.
// This will run the tests directly.
return
Promise
.
all
(
allSpecFiles
.
map
(
function
(
moduleName
)
{
return
System
.
import
(
moduleName
);
}));
.
then
(
function
()
{
// Finally, load all spec files.
// This will run the tests directly.
return
Promise
.
all
(
allSpecFiles
.
map
(
function
(
moduleName
)
{
return
System
.
import
(
moduleName
);
}));
})
.
then
(
__karma__
.
start
,
__karma__
.
error
);
karma.conf.js
View file @
d8b3ba7e
...
...
@@ -30,9 +30,10 @@ module.exports = function(config) {
// Reflect and Zone.js
'
node_modules/reflect-metadata/Reflect.js
'
,
'
node_modules/zone.js/dist/zone.js
'
,
'
node_modules/zone.js/dist/jasmine-patch.js
'
,
'
node_modules/zone.js/dist/async-test.js
'
,
'
node_modules/zone.js/dist/fake-async-test.js
'
,
'
node_modules/zone.js/dist/sync-test.js
'
,
'
node_modules/zone.js/dist/proxy-zone.js
'
,
// RxJs.
{
pattern
:
'
node_modules/rxjs/**/*.js
'
,
included
:
false
,
watched
:
false
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment