Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from krux/fix/more-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Yates authored Sep 17, 2016
2 parents 7c781db + b60e34d commit 39b236c
Show file tree
Hide file tree
Showing 60 changed files with 2,352 additions and 386 deletions.
File renamed without changes.
27 changes: 27 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## What does this Pull Request do?

<short description>

## Why is this change being made?

<explain why>

## Where should the reviewer start?

<help orientate the reviewer>

## How was this tested? How can the reviewer verify your testing?

<step-by-step instructions>
<preferrably, add a failing unit test in `test/bugs/issue<ISSUE_ID>.spec.js`.>

## What gif best describes this PR or how it makes you feel?

![](SOMEURL)

## Completion checklist

- [ ] The pull request has been appropriately labelled according to our conventions.
- [ ] Documentation has been updated.
- [ ] The change has unit & integration tests as appropriate.

3 changes: 2 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"preset": "google",
"maximumLineLength": null,
"validateQuoteMarks": { "mark": "'", "escape": true }
"validateQuoteMarks": { "mark": "'", "escape": true },
"jsDoc": false
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
[![Dependencies](https://img.shields.io/david/dev/krux/gpt-mock.svg)](./package.json)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Gitter](https://badges.gitter.im/krux/gpt-mock.svg)](https://gitter.im/krux/gpt-mock)

A test library to mock out the Google Publisher Tag library.

Expand Down Expand Up @@ -75,7 +74,7 @@ worked on, please [file a new issue](https://github.com/krux/gpt-mock/issues/new

We ♥ [forks and pull requests](https://help.github.com/articles/using-pull-requests).

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for full details.
Please see [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for full details.

## Environment

Expand Down Expand Up @@ -124,7 +123,7 @@ npm run tdd

## Issue Guidelines

Please either add a failing [unit test](./test/unit) or include a [jsfiddle](http://jsfiddle.net) that distills and reproduces the issue.
Please add a failing [bug test](./test/bugs) and create a Pull Request.

# License

Expand Down
27 changes: 27 additions & 0 deletions esdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"title": "gpt-mock",
"destination": "./docs",
"lint": true,
"manual": {
"overview": ["./manual/Overview.md"],
"installation": ["./manual/Installation.md"],
"example": ["./manual/Example.md"]
},
"test": {
"type": "mocha",
"source": "./test/unit"
},
"plugins": [
{
"name": "esdoc-importpath-plugin",
"option": {
"replaces": [
{
"from": "^src/",
"to": "dist/"
}
]
}
}
]
}
5 changes: 2 additions & 3 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import eslint from 'gulp-eslint';
import jscs from 'gulp-jscs';
import header from 'gulp-header';
import esdoc from 'gulp-esdoc';
import esdocConfig from './esdoc.json';

const DIST = 'dist';

Expand Down Expand Up @@ -68,9 +69,7 @@ gulp.task('build', build(webpackConfig));

gulp.task('doc', () => {
return gulp.src('./src')
.pipe(esdoc({
destination: './doc'
}));
.pipe(esdoc(esdocConfig));
});

gulp.task('lint', ['lint:eslint', 'lint:jscs']);
Expand Down
18 changes: 18 additions & 0 deletions manual/Example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example

```javascript
import GPT from 'gpt-mock';

googletag = new GPT();
googletag.cmd.push(function() {
googletag.defineSlot('/Test/12345', [728, 90], 'gpt-div-1').addService(googletag.pubads());
});

googletag.cmd.push(function() {
googletag.display('gpt-div-1');
});

// Vitally, you need to tell the library that it has loaded so the commands
// will be executed.
googletag._loaded();
```
6 changes: 6 additions & 0 deletions manual/Installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Installation

## From npm
```bash
npm install -D gpt-mock
```
12 changes: 12 additions & 0 deletions manual/Overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Overview

`gpt-mock` is a testing library for mocking out the `Google Publisher Tag` (`GPT`) library, so you
can test your site or library for how it interacts with `GPT` without using the production library.

## Author

Seth Yates

## License

[Apache 2](../LICENSE)
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Test library for mocking out Google Publisher Tags",
"homepage": "https://github.com/krux/gpt-mock/",
"bugs": "https://github.com/krux/gpt-mock/issues",
"license": "Apache-2",
"license": "Apache-2.0",
"keywords": [
"gpt",
"dfp",
Expand Down Expand Up @@ -65,14 +65,15 @@
"babel-plugin-transform-es3-member-expression-literals": "6.8.0",
"babel-plugin-transform-es3-property-literals": "6.8.0",
"babel-plugin-transform-object-assign": "6.8.0",
"babel-plugin-transform-runtime": "6.12.0",
"babel-plugin-transform-runtime": "6.15.0",
"babel-preset-es2015": "6.14.0",
"babel-preset-es2015-loose": "7.0.0",
"babel-preset-es2015-loose": "8.0.0",
"babel-register": "6.14.0",
"babelify": "7.3.0",
"cz-conventional-changelog": "1.2.0",
"del": "2.2.2",
"eslint": "3.4.0",
"esdoc-importpath-plugin": "0.0.1",
"eslint": "3.5.0",
"expect.js": "0.3.1",
"gulp": "3.9.1",
"gulp-babel": "6.1.2",
Expand All @@ -86,25 +87,25 @@
"istanbul": "0.4.5",
"jscs": "3.0.7",
"json-loader": "0.5.4",
"karma": "1.2.0",
"karma": "1.3.0",
"karma-babel-preprocessor": "6.0.1",
"karma-coverage": "1.1.1",
"karma-coveralls": "1.1.2",
"karma-expect": "1.1.2",
"karma-mocha": "1.1.1",
"karma-mocha-reporter": "2.1.0",
"karma-phantomjs-launcher": "1.0.1",
"karma-phantomjs-launcher": "1.0.2",
"karma-sinon": "1.0.5",
"karma-webpack": "1.8.0",
"lolex": "1.5.1",
"mocha": "3.0.2",
"phantomjs-prebuilt": "2.1.12",
"process": "0.11.8",
"semantic-release": "^4.3.5",
"process": "0.11.9",
"semantic-release": "4.3.5",
"sinon": "1.17.5",
"watchify": "3.7.0",
"webpack": "1.13.2",
"webpack-dev-server": "1.15.0",
"webpack-dev-server": "1.15.2",
"webpack-stream": "3.2.0"
}
}
10 changes: 6 additions & 4 deletions src/CommandArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
export default class CommandArray {
/**
* Creates a new CommandArray.
* Creates a new {@link CommandArray}.
*
* @param {Array<function()>} commands The commands to execute
*/
Expand All @@ -21,11 +21,13 @@ export default class CommandArray {
*
* @param {function()} f A JavaScript function to be executed.
* @returns {number} The number of commands processed so far. This is
* compatible with Array.push's return value (the current length of the array).
* compatible with {@link Array#push}'s return value (the current length of the array).
*/
push(f) {
f();
this._count += 1;
if (f != null && typeof f === 'function') {
f();
this._count += 1;
}
return this._count;
}
}
18 changes: 12 additions & 6 deletions src/CompanionAdsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@ export default class CompanionAdsService extends Service {
/**
* Creates a new CompanionAdsService.
*
* @param {GPT} gt The containing GPT instance.
* @param {GPT} gpt The containing {@link GPT} instance.
*/
constructor(gt) {
super(gt, CompanionAdsService._name);
constructor(gpt) {
super(gpt, CompanionAdsService._name);
this._options = {
syncLoading: false,
refreshUnfilledSlots: null
};
}

/**
* The name of the service.
*
* @type {string}
* @private
*/
static get _name() {
return 'companion_ads';
}

/**
* Enables the service implementation to be loaded synchronously. This needs
* to be called before {@link GPT#enableServices()}.
* to be called before {@link GPT#enableServices}.
*
* Note: this call can be only used if gpt.js is also loaded synchronously,
* for example, by using a script element. If called when GPT is loaded
* for example, by using a script element. If called when {@link GPT} is loaded
* asynchronously, the outcome of the loading is undefined.
*/
enableSyncLoading() {
Expand All @@ -35,7 +41,7 @@ export default class CompanionAdsService extends Service {

/**
* Sets whether companion slots that have not been filled will be automatically
* backfilled. Only slots that are also registered with the pubads service will
* backfilled. Only slots that are also registered with the {@link PubAdsService} will
* be backfilled. This method can be called multiple times during the page's
* lifetime to turn backfill on and off.
*
Expand Down
22 changes: 17 additions & 5 deletions src/ContentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@ import Service from './Service';
*/
export default class ContentService extends Service {
/**
* Creates a new ContentService.
* Creates a new {@link ContentService}.
*
* @param {GPT} gt The containing GPT instance.
* @param {GPT} gpt The containing {@link GPT} instance.
*/
constructor(gt) {
super(gt, ContentService._name);
constructor(gpt) {
super(gpt, ContentService._name);
this._storedContent = [];
}

/**
* The name of the service.
*
* @type {string}
* @private
*/
static get _name() {
return 'content';
}

_onEnable() {
/**
* Enables the service.
*
* @override
*/
enable() {
super.enable();
for (let [slot, content] of this._storedContent) {
slot._setContent(content);
}
Expand Down
Loading

0 comments on commit 39b236c

Please sign in to comment.