Skip to content

Commit

Permalink
Make tests check for content in browser context
Browse files Browse the repository at this point in the history
* Update fixtures to insert content inside #app div
* Add assertion for requestTestPage and files generated.
  • Loading branch information
davidmpaz committed Jun 24, 2017
1 parent 822ceff commit 356aaa2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fixtures/js/render.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function render() {
document.getElementById('wrapper').innerHTML = "<h1> Hello World!</h1>";
document.getElementById('app').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";
}

export = render;
2 changes: 1 addition & 1 deletion fixtures/js/render2.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function render() {
document.getElementById('wrapper').innerHTML = "<h1> Hello World!</h1>";
document.getElementById('app').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";
}

export = render;
1 change: 1 addition & 0 deletions lib/test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function requestTestPage(webRootDir, scriptSrcs, callback) {
<head>
</head>
<body>
<div id="app"></div>
${scripts}
</body>
</html>
Expand Down
30 changes: 27 additions & 3 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,29 @@ module.exports = {
// check that ts-loader transformed the ts file
webpackAssert.assertOutputFileContains(
'main.js',
'document.getElementById(\'wrapper\').innerHTML = "<h1> Hello World!</h1>";'
'document.getElementById(\'app\').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";'
);

done();
expect(config.outputPath).to.be.a.directory().with.deep.files([
'main.js',
'manifest.json'
]);

testSetup.requestTestPage(
path.join(config.getContext(), 'www'),
[
'build/main.js'
],
(browser) => {

// assert that the ts module rendered
browser.assert.text('#app h1', 'Welcome to Your TypeScript App');
// make sure the styles are not inline
browser.assert.elements('style', 0);

done();
}
);
});
});

Expand All @@ -620,9 +639,14 @@ module.exports = {
// and also ts-loader did its job
webpackAssert.assertOutputFileContains(
'main.js',
'document.getElementById(\'wrapper\').innerHTML = "<h1> Hello World!</h1>";'
'document.getElementById(\'app\').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";'
);

expect(config.outputPath).to.be.a.directory().with.deep.files([
'main.js',
'manifest.json'
]);

done();
});
});
Expand Down

0 comments on commit 356aaa2

Please sign in to comment.