mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Adds tests for constructor
This commit is contained in:
parent
b1d0ac9520
commit
ec20389775
@ -14,6 +14,7 @@
|
||||
"devDependencies": {
|
||||
"babelify": "^6.3.0",
|
||||
"browserify": "^11.1.0",
|
||||
"chai": "^3.2.0",
|
||||
"mocha": "^2.3.2",
|
||||
"uglify": "^0.1.5"
|
||||
},
|
||||
|
@ -1,3 +1,28 @@
|
||||
describe('Clipboard', () => {
|
||||
var assert = chai.assert;
|
||||
|
||||
describe('Clipboard', () => {
|
||||
describe('#constructor', () => {
|
||||
it('should throw an error since there was no arguments passed', done => {
|
||||
try {
|
||||
new Clipboard();
|
||||
}
|
||||
catch(e) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error since an empty selector has been passed', done => {
|
||||
try {
|
||||
new Clipboard('#abc');
|
||||
}
|
||||
catch(e) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should create a NodeList and store it in a property', () => {
|
||||
let clipboard = new Clipboard('.btn');
|
||||
return assert.instanceOf(clipboard.triggers, NodeList);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -7,8 +7,26 @@
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<div>
|
||||
<p>Copy text from attribute</p>
|
||||
<button class="btn" data-action="copy" data-text="hello">Copy</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>Copy text from another element</p>
|
||||
<input id="foo" type="text" value="hello">
|
||||
<button class="btn" data-action="copy" data-target="foo">Copy</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>Cut text from another element</p>
|
||||
<textarea id="bar">hello</textarea>
|
||||
<button class="btn" data-action="cut" data-target="bar">Cut</button>
|
||||
</div>
|
||||
|
||||
<script src="../dist/clipboard.min.js"></script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
|
||||
<script>mocha.setup('bdd')</script>
|
||||
<script src="clipboard.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user