-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
379 additions
and
223 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,101 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
<script src="../../webcomponentsjs/webcomponents-loader.js"></script> | ||
<script src="../../web-component-tester/browser.js"></script> | ||
<link rel="import" href="../../raml-aware/raml-aware.html"> | ||
<link rel="import" href="../../arc-polyfills/arc-polyfills.html"> | ||
<link rel="import" href="../api-console.html"> | ||
<script src="amf-loader.js"></script> | ||
</head> | ||
<body> | ||
|
||
<test-fixture id="Basic"> | ||
<template> | ||
<api-console></api-console> | ||
</template> | ||
</test-fixture> | ||
|
||
<test-fixture id="NoExtension"> | ||
<template> | ||
<api-console no-extension-banner></api-console> | ||
</template> | ||
</test-fixture> | ||
|
||
<script> | ||
suite('Declarative use', () => { | ||
test('extensionBannerActive is eventually set', (done) => { | ||
const element = fixture('NoExtension'); | ||
element.page = 'request'; | ||
flush(() => { | ||
assert.isUndefined(element.extensionBannerActive); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('The extension banner is not visible', (done) => { | ||
const element = fixture('NoExtension'); | ||
element.page = 'request'; | ||
flush(() => { | ||
const node = element.shadowRoot.querySelector('.extension-banner'); | ||
const result = getComputedStyle(node).display.trim(); | ||
assert.equal(result, 'none'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
suite('Banner flow', () => { | ||
let element; | ||
setup(() => { | ||
element = fixture('Basic'); | ||
element.page = 'request'; | ||
}); | ||
|
||
test('extensionBannerActive is set', (done) => { | ||
if (!element.isChrome) { | ||
done(); | ||
return; | ||
} | ||
flush(() => { | ||
assert.isTrue(element.extensionBannerActive); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('Renders extension banner', (done) => { | ||
if (!element.isChrome) { | ||
done(); | ||
return; | ||
} | ||
flush(() => { | ||
const node = element.shadowRoot.querySelector('.extension-banner'); | ||
const result = getComputedStyle(node).display.trim(); | ||
assert.notEqual(result, 'none'); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('The banner is hidden when extension is detected', (done) => { | ||
if (!element.isChrome) { | ||
done(); | ||
return; | ||
} | ||
window.postMessage({ | ||
'api-console-payload': 'init', | ||
'api-console-extension': true | ||
}, location.origin); | ||
flush(() => { | ||
assert.isUndefined(element.extensionBannerActive); | ||
const node = element.shadowRoot.querySelector('.extension-banner'); | ||
const result = getComputedStyle(node).display.trim(); | ||
assert.equal(result, 'none'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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