Skip to content

Commit

Permalink
docs: add fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Åström committed Mar 13, 2019
1 parent f8dce63 commit 492f0e4
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
50 changes: 50 additions & 0 deletions docs/protractor-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,56 @@ id: protractor-examples
title: Protractor
---

```javascript
<html lang="en">

<head>
<title>Test</title>
<meta charset="utf-8">
<base href="/">
<style>
#container {
width: 100%;
height: 100%;
}
</style>
</head>

<body>
<div id="container">
hello world
</div>
</body>

</html>
```

**[examples/protractor/test/hello.fix.html](https://github.com/qlik-oss/after-work.js/tree/master/examples/protractor/test/hello.fix.html)**

```javascript
<html lang="en">
<head>
<title>Test</title>
<meta charset="utf-8" />
<base href="/" />
<style>
#container {
width: 100%;
height: 100%;
}
</style>
</head>

<body>
<div id="container" style="background: red">
hepp
</div>
</body>
</html>
```

**[examples/protractor/test/rendering/rendering.fix.html](https://github.com/qlik-oss/after-work.js/tree/master/examples/protractor/test/rendering/rendering.fix.html)**

```javascript
describe('Protractor', () => {
it('should say hello world', async () => {
Expand Down
34 changes: 34 additions & 0 deletions docs/puppeteer-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@ id: puppeteer-examples
title: Puppeteer
---

```javascript
<html lang="en">
<head>
<title>Test</title>
<meta charset="utf-8" />
<base href="/" />
<style>
#container {
width: 100%;
height: 100%;
}
</style>
</head>

<body>
<div id="container" onclick="getData();">hello world</div>
<script>
window.getData = () => {
const container = document.querySelector("#container");
fetch("http://localhost:9677/my/fancy/api")
.then(response => {
response.text().then(txt => (container.innerHTML = txt));
})
.catch(err => {
container.innerHTML = err.toString();
});
};
</script>
</body>
</html>
```

**[examples/puppeteer/test/hello.fix.html](https://github.com/qlik-oss/after-work.js/tree/master/examples/puppeteer/test/hello.fix.html)**

```javascript
describe('Puppeteer', () => {
it('should say hello world', async () => {
Expand Down
8 changes: 7 additions & 1 deletion scripts/generate-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ id: ${example.name}-examples
title: ${example.name.charAt(0).toUpperCase() + example.name.slice(1)}
---\n\n`;

const files = globby.sync(`${example.p}/test/**/*.spec.{js,ts}`);
const appendFile = (file) => {
md += `\`\`\`javascript\n${fs.readFileSync(file, 'utf8')}\`\`\`\n\n`;
md += `**[${file}](${baseUrl}/${file})**\n\n`;
};

const fixtureFiles = globby.sync(`${example.p}/test/**/*.fix.html`);
for (const file of fixtureFiles) {
appendFile(file);
}

const files = globby.sync(`${example.p}/test/**/*.spec.{js,ts}`);
for (const file of files) {
appendFile(file);
}
Expand Down

0 comments on commit 492f0e4

Please sign in to comment.