-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
2 changed files
with
29 additions
and
35 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,42 +1,40 @@ | ||
import * as chai from '../index.js'; | ||
import {use, expect} from '../index.js'; | ||
|
||
describe('plugins', function () { | ||
function plugin(chai) { | ||
if (chai.Assertion.prototype.testing) return; | ||
|
||
Object.defineProperty(chai.Assertion.prototype, 'testing', { | ||
get: function () { | ||
return 'successful'; | ||
}, | ||
}); | ||
} | ||
|
||
function plugin (chai) { | ||
if (chai.Assertion.prototype.testing) return; | ||
function anotherPlugin(chai) { | ||
if (chai.Assertion.prototype.moreTesting) return; | ||
|
||
Object.defineProperty(chai.Assertion.prototype, 'testing', { | ||
get: function () { | ||
return 'successful'; | ||
} | ||
}); | ||
} | ||
Object.defineProperty(chai.Assertion.prototype, 'moreTesting', { | ||
get: function () { | ||
return 'more success'; | ||
}, | ||
}); | ||
} | ||
|
||
describe('plugins', function () { | ||
it('basic usage', function () { | ||
chai.use(plugin); | ||
var expect = chai.expect; | ||
const {expect} = use(plugin); | ||
expect(expect('').testing).to.equal('successful'); | ||
}); | ||
|
||
it('double plugin', function () { | ||
chai.expect(function () { | ||
chai.use(plugin); | ||
it('multiple plugins', function () { | ||
expect(function () { | ||
use(plugin).use(anotherPlugin); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('.use detached from chai object', function () { | ||
function anotherPlugin (chai) { | ||
Object.defineProperty(chai.Assertion.prototype, 'moreTesting', { | ||
get: function () { | ||
return 'more success'; | ||
} | ||
}); | ||
} | ||
|
||
var use = chai.use; | ||
use(anotherPlugin); | ||
|
||
var expect = chai.expect; | ||
const {expect} = use(anotherPlugin); | ||
|
||
expect(expect('').moreTesting).to.equal('more success'); | ||
}); | ||
}); |